After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 598526 - bytewriter: fails to compile with gcc 4.2.4 on Ubuntu Hardy 64 bits
bytewriter: fails to compile with gcc 4.2.4 on Ubuntu Hardy 64 bits
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
git master
Other Linux
: Normal blocker
: 0.10.26
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2009-10-15 09:53 UTC by Alexandre Poltorak
Modified: 2009-11-20 16:19 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Proposed fix for this issue. (2.25 KB, patch)
2009-11-20 11:36 UTC, Julien MOUTTE
reviewed Details | Review
Patch to try (837 bytes, patch)
2009-11-20 12:49 UTC, Tim-Philipp Müller
committed Details | Review

Description Alexandre Poltorak 2009-10-15 09:53:50 UTC
I got this error compiling gstreamer from git:

  CC    gstbytewriter.o
cc1: warnings being treated as errors
gstbytewriter.c: In function ‘gst_byte_writer_put_float64_le’:
gstbytewriter.c:474: warning: passing argument 1 of ‘GST_WRITE_DOUBLE_LE’ discards qualifiers from pointer target type
make[4]: *** [libgstbase_0.10_la-gstbytewriter.lo] Error 1
make[3]: *** [all-recursive] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

after changing line 445 as suggested by slomo
"(guint8 *) &writer->parent.data[writer->parent.byte]"
to 
"((guint8 *) &writer->parent.data[writer->parent.byte])"

I got:

  CC    gstbytewriter.o
gstbytewriter.c:452:1: error: macro "GST_WRITE_UINT8" requires 2 arguments, but only 1 given
gstbytewriter.c: In function ‘gst_byte_writer_put_uint8’:
gstbytewriter.c:452: error: ‘GST_WRITE_UINT8’ undeclared (first use in this function)
gstbytewriter.c:452: error: (Each undeclared identifier is reported only once
gstbytewriter.c:452: error: for each function it appears in.)
cc1: warnings being treated as errors
gstbytewriter.c:452: warning: left-hand operand of comma expression has no effect
gstbytewriter.c:452: warning: statement with no effect
gstbytewriter.c:452: error: expected ‘;’ before ‘)’ token
gstbytewriter.c:452: error: expected statement before ‘)’ token
gstbytewriter.c:453:1: error: macro "GST_WRITE_UINT8" requires 2 arguments, but only 1 given
gstbytewriter.c: In function ‘gst_byte_writer_put_int8’:
gstbytewriter.c:453: error: ‘GST_WRITE_UINT8’ undeclared (first use in this function)
gstbytewriter.c:453: warning: left-hand operand of comma expression has no effect
gstbytewriter.c:453: warning: statement with no effect
gstbytewriter.c:453: error: expected ‘;’ before ‘)’ token
gstbytewriter.c:453: error: expected statement before ‘)’ token
gstbytewriter.c:454:1: error: macro "GST_WRITE_UINT16_LE" requires 2 arguments, but only 1 given
gstbytewriter.c: In function ‘gst_byte_writer_put_uint16_le’:
gstbytewriter.c:454: error: ‘GST_WRITE_UINT16_LE’ undeclared (first use in this function)
gstbytewriter.c:454: warning: left-hand operand of comma expression has no effect
gstbytewriter.c:454: warning: statement with no effect
gstbytewriter.c:454: error: expected ‘;’ before ‘)’ token
gstbytewriter.c:454: error: expected statement before ‘)’ token
gstbytewriter.c:455:1: error: macro "GST_WRITE_UINT16_BE" requires 2 arguments, but only 1 given
gstbytewriter.c: In function ‘gst_byte_writer_put_uint16_be’:
gstbytewriter.c:455: error: ‘GST_WRITE_UINT16_BE’ undeclared (first use in this function)
gstbytewriter.c:455: warning: left-hand operand of comma expression has no effect
gstbytewriter.c:455: warning: statement with no effect
gstbytewriter.c:455: error: expected ‘;’ before ‘)’ token
gstbytewriter.c:455: error: expected statement before ‘)’ token
gstbytewriter.c:456:1: error: macro "GST_WRITE_UINT16_LE" requires 2 arguments, but only 1 given
gstbytewriter.c: In function ‘gst_byte_writer_put_int16_le’:
gstbytewriter.c:456: error: ‘GST_WRITE_UINT16_LE’ undeclared (first use in this function)
gstbytewriter.c:456: warning: left-hand operand of comma expression has no effect
gstbytewriter.c:456: warning: statement with no effect
gstbytewriter.c:456: error: expected ‘;’ before ‘)’ token
gstbytewriter.c:456: error: expected statement before ‘)’ token
gstbytewriter.c:457:1: error: macro "GST_WRITE_UINT16_BE" requires 2 arguments, but only 1 given
gstbytewriter.c: In function ‘gst_byte_writer_put_int16_be’:
gstbytewriter.c:457: error: ‘GST_WRITE_UINT16_BE’ undeclared (first use in this function)
gstbytewriter.c:457: warning: left-hand operand of comma expression has no effect
gstbytewriter.c:457: warning: statement with no effect
gstbytewriter.c:457: error: expected ‘;’ before ‘)’ token
gstbytewriter.c:457: error: expected statement before ‘)’ token
gstbytewriter.c:458:1: error: macro "GST_WRITE_UINT24_LE" requires 2 arguments, but only 1 given
gstbytewriter.c: In function ‘gst_byte_writer_put_uint24_le’:
gstbytewriter.c:458: error: ‘GST_WRITE_UINT24_LE’ undeclared (first use in this function)
gstbytewriter.c:458: warning: left-hand operand of comma expression has no effect
gstbytewriter.c:458: warning: statement with no effect
gstbytewriter.c:458: error: expected ‘;’ before ‘)’ token
gstbytewriter.c:458: error: expected statement before ‘)’ token
gstbytewriter.c:459:1: error: macro "GST_WRITE_UINT24_BE" requires 2 arguments, but only 1 given
gstbytewriter.c: In function ‘gst_byte_writer_put_uint24_be’:
gstbytewriter.c:459: error: ‘GST_WRITE_UINT24_BE’ undeclared (first use in this function)
gstbytewriter.c:459: warning: left-hand operand of comma expression has no effect
gstbytewriter.c:459: warning: statement with no effect
gstbytewriter.c:459: error: expected ‘;’ before ‘)’ token
gstbytewriter.c:459: error: expected statement before ‘)’ token
gstbytewriter.c:460:1: error: macro "GST_WRITE_UINT24_LE" requires 2 arguments, but only 1 given
gstbytewriter.c: In function ‘gst_byte_writer_put_int24_le’:
gstbytewriter.c:460: error: ‘GST_WRITE_UINT24_LE’ undeclared (first use in this function)
gstbytewriter.c:460: warning: left-hand operand of comma expression has no effect
gstbytewriter.c:460: warning: statement with no effect
gstbytewriter.c:460: error: expected ‘;’ before ‘)’ token
gstbytewriter.c:460: error: expected statement before ‘)’ token
gstbytewriter.c:461:1: error: macro "GST_WRITE_UINT24_BE" requires 2 arguments, but only 1 given
gstbytewriter.c: In function ‘gst_byte_writer_put_int24_be’:
gstbytewriter.c:461: error: ‘GST_WRITE_UINT24_BE’ undeclared (first use in this function)
gstbytewriter.c:461: warning: left-hand operand of comma expression has no effect
gstbytewriter.c:461: warning: statement with no effect
gstbytewriter.c:461: error: expected ‘;’ before ‘)’ token
gstbytewriter.c:461: error: expected statement before ‘)’ token
gstbytewriter.c:462:1: error: macro "GST_WRITE_UINT32_LE" requires 2 arguments, but only 1 given
gstbytewriter.c: In function ‘gst_byte_writer_put_uint32_le’:
gstbytewriter.c:462: error: ‘GST_WRITE_UINT32_LE’ undeclared (first use in this function)
gstbytewriter.c:462: warning: left-hand operand of comma expression has no effect
gstbytewriter.c:462: warning: statement with no effect
gstbytewriter.c:462: error: expected ‘;’ before ‘)’ token
gstbytewriter.c:462: error: expected statement before ‘)’ token
gstbytewriter.c:463:1: error: macro "GST_WRITE_UINT32_BE" requires 2 arguments, but only 1 given
gstbytewriter.c: In function ‘gst_byte_writer_put_uint32_be’:
gstbytewriter.c:463: error: ‘GST_WRITE_UINT32_BE’ undeclared (first use in this function)
gstbytewriter.c:463: warning: left-hand operand of comma expression has no effect
gstbytewriter.c:463: warning: statement with no effect
gstbytewriter.c:463: error: expected ‘;’ before ‘)’ token
gstbytewriter.c:463: error: expected statement before ‘)’ token
gstbytewriter.c:464:1: error: macro "GST_WRITE_UINT32_LE" requires 2 arguments, but only 1 given
gstbytewriter.c: In function ‘gst_byte_writer_put_int32_le’:
gstbytewriter.c:464: error: ‘GST_WRITE_UINT32_LE’ undeclared (first use in this function)
gstbytewriter.c:464: warning: left-hand operand of comma expression has no effect
gstbytewriter.c:464: warning: statement with no effect
gstbytewriter.c:464: error: expected ‘;’ before ‘)’ token
gstbytewriter.c:464: error: expected statement before ‘)’ token
gstbytewriter.c:465:1: error: macro "GST_WRITE_UINT32_BE" requires 2 arguments, but only 1 given
gstbytewriter.c: In function ‘gst_byte_writer_put_int32_be’:
gstbytewriter.c:465: error: ‘GST_WRITE_UINT32_BE’ undeclared (first use in this function)
gstbytewriter.c:465: warning: left-hand operand of comma expression has no effect
gstbytewriter.c:465: warning: statement with no effect
gstbytewriter.c:465: error: expected ‘;’ before ‘)’ token
gstbytewriter.c:465: error: expected statement before ‘)’ token
gstbytewriter.c:466:1: error: macro "GST_WRITE_UINT64_LE" requires 2 arguments, but only 1 given
gstbytewriter.c: In function ‘gst_byte_writer_put_uint64_le’:
gstbytewriter.c:466: error: ‘GST_WRITE_UINT64_LE’ undeclared (first use in this function)
gstbytewriter.c:466: warning: left-hand operand of comma expression has no effect
gstbytewriter.c:466: warning: statement with no effect
gstbytewriter.c:466: error: expected ‘;’ before ‘)’ token
gstbytewriter.c:466: error: expected statement before ‘)’ token
gstbytewriter.c:467:1: error: macro "GST_WRITE_UINT64_BE" requires 2 arguments, but only 1 given
gstbytewriter.c: In function ‘gst_byte_writer_put_uint64_be’:
gstbytewriter.c:467: error: ‘GST_WRITE_UINT64_BE’ undeclared (first use in this function)
gstbytewriter.c:467: warning: left-hand operand of comma expression has no effect
gstbytewriter.c:467: warning: statement with no effect
gstbytewriter.c:467: error: expected ‘;’ before ‘)’ token
gstbytewriter.c:467: error: expected statement before ‘)’ token
gstbytewriter.c:468:1: error: macro "GST_WRITE_UINT64_LE" requires 2 arguments, but only 1 given
gstbytewriter.c: In function ‘gst_byte_writer_put_int64_le’:
gstbytewriter.c:468: error: ‘GST_WRITE_UINT64_LE’ undeclared (first use in this function)
gstbytewriter.c:468: warning: left-hand operand of comma expression has no effect
gstbytewriter.c:468: warning: statement with no effect
gstbytewriter.c:468: error: expected ‘;’ before ‘)’ token
gstbytewriter.c:468: error: expected statement before ‘)’ token
gstbytewriter.c:469:1: error: macro "GST_WRITE_UINT64_BE" requires 2 arguments, but only 1 given
gstbytewriter.c: In function ‘gst_byte_writer_put_int64_be’:
gstbytewriter.c:469: error: ‘GST_WRITE_UINT64_BE’ undeclared (first use in this function)
gstbytewriter.c:469: warning: left-hand operand of comma expression has no effect
gstbytewriter.c:469: warning: statement with no effect
gstbytewriter.c:469: error: expected ‘;’ before ‘)’ token
gstbytewriter.c:469: error: expected statement before ‘)’ token
gstbytewriter.c: In function ‘gst_byte_writer_put_float32_be’:
gstbytewriter.c:471: error: too few arguments to function ‘GST_WRITE_FLOAT_BE’
gstbytewriter.c:471: warning: left-hand operand of comma expression has no effect
gstbytewriter.c:471: warning: statement with no effect
gstbytewriter.c:471: error: expected ‘;’ before ‘)’ token
gstbytewriter.c:471: error: expected statement before ‘)’ token
gstbytewriter.c: In function ‘gst_byte_writer_put_float32_le’:
gstbytewriter.c:472: error: too few arguments to function ‘GST_WRITE_FLOAT_LE’
gstbytewriter.c:472: warning: left-hand operand of comma expression has no effect
gstbytewriter.c:472: warning: statement with no effect
gstbytewriter.c:472: error: expected ‘;’ before ‘)’ token
gstbytewriter.c:472: error: expected statement before ‘)’ token
gstbytewriter.c: In function ‘gst_byte_writer_put_float64_be’:
gstbytewriter.c:473: error: too few arguments to function ‘GST_WRITE_DOUBLE_BE’
gstbytewriter.c:473: warning: left-hand operand of comma expression has no effect
gstbytewriter.c:473: warning: statement with no effect
gstbytewriter.c:473: error: expected ‘;’ before ‘)’ token
gstbytewriter.c:473: error: expected statement before ‘)’ token
gstbytewriter.c: In function ‘gst_byte_writer_put_float64_le’:
gstbytewriter.c:474: error: too few arguments to function ‘GST_WRITE_DOUBLE_LE’
gstbytewriter.c:474: warning: left-hand operand of comma expression has no effect
gstbytewriter.c:474: warning: statement with no effect
gstbytewriter.c:474: error: expected ‘;’ before ‘)’ token
gstbytewriter.c:474: error: expected statement before ‘)’ token
make[4]: *** [libgstbase_0.10_la-gstbytewriter.lo] Error 1
make[3]: *** [all-recursive] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
Comment 1 Sebastian Dröge (slomo) 2009-10-15 12:32:13 UTC
Which gcc version are you using?
Comment 2 Julien MOUTTE 2009-10-16 09:51:11 UTC
I have the same warning/error on Ubuntu Hardy 64 bits :

gcc (GCC) 4.2.4 (Ubuntu 4.2.4-1ubuntu4)
Comment 3 Alexandre Poltorak 2009-10-16 10:29:18 UTC
I have gcc (GCC) 4.2.4 (Ubuntu 4.2.4-5ubuntu1) on Ubuntu Hardy 64 bits.

I tried a 4 days old git version from a friend that compile on his PC (32 bits Ubuntu).
Comment 4 Tim-Philipp Müller 2009-10-21 14:03:58 UTC
Julien: any chance you could figure out a workaround?
Comment 5 Julien MOUTTE 2009-11-20 11:36:31 UTC
Created attachment 148166 [details] [review]
Proposed fix for this issue.

ByteReader data array is a const pointer and the new WRITE macros (which are now functions) are discarding the const qualifier. I propose to make the new WRITE macros take a const pointer and adapt bytewriter accordingly.
Comment 6 Tim-Philipp Müller 2009-11-20 12:49:50 UTC
Created attachment 148169 [details] [review]
Patch to try

We can't change the GST_WRITE_FOO() macros/functions to take a const pointer as first argument.

So basically the compiler ignores the (guint8 *) cast here?

Could you try the attached patch? Maybe that works.
Comment 7 Julien MOUTTE 2009-11-20 15:37:37 UTC
Ok, this patch builds and works as well.
Comment 8 Tim-Philipp Müller 2009-11-20 16:16:38 UTC
Great, thanks for your help!

 commit 022970e9f911da45215ae4faa4cf40d0bf1ddce2
 Author: Tim-Philipp Müller <tim.muller@collabora.co.uk>
 Date:   Fri Nov 20 16:00:47 2009 +0000

    bytewriter: fix compiler warning
    
    Some gcc versions warn about bytewriter writing to memory accessed
    via a const guint8 pointer, despite our explicit cast to guint8 *.
    Work around that by using an intermediary variable.
    
    Fixes #598526.