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 615698 - "warning: cast increases required alignment of target type" with gcc 4.2.1 on arm
"warning: cast increases required alignment of target type" with gcc 4.2.1 on...
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
git master
Other Linux
: Normal normal
: 0.10.29
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2010-04-14 00:51 UTC by Tim-Philipp Müller
Modified: 2011-07-07 16:54 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
warnings.log (271.84 KB, application/octet-stream)
2010-04-14 00:51 UTC, Tim-Philipp Müller
  Details
configure: Remove -Wcast-align (1.55 KB, patch)
2010-04-14 11:17 UTC, Benjamin Otte (Company)
committed Details | Review
configure: Drop -Wcast-align (1.55 KB, patch)
2010-04-15 10:17 UTC, Thiago Sousa Santos
committed Details | Review
configure: Drop -Wcast-align (1.67 KB, patch)
2010-04-15 10:19 UTC, Thiago Sousa Santos
committed Details | Review

Description Tim-Philipp Müller 2010-04-14 00:51:18 UTC
Created attachment 158664 [details]
warnings.log

When compiling GStreamer git in scratchbox, the following warnings appear pretty much for all GObject instance/class structure casts:

warning: cast increases required alignment of target type

$ gcc --version
sbox-arm-none-linux-gnueabi-gcc (GCC) 4.2.1

$ uname -a
Linux debian 2.6.30-1-686 #1 SMP Sat Aug 15 19:11:58 UTC 2009 arm GNU/Linux

Log attached. Some strategic __atribute__((aligned)) here and here help a little, but it seems to affect pretty much all inherited structures afaict.
Comment 1 Benjamin Otte (Company) 2010-04-14 07:27:41 UTC
That's pretty gross, in particular because all those warnings are wrong - GstMessage, GstEvent, GstBuffer and GstMiniObject all have the same required alignment. (Or am I missing something?)

I wonder if newer gcc versions have that fixed?
Comment 2 Benjamin Otte (Company) 2010-04-14 11:17:04 UTC
Created attachment 158707 [details] [review]
configure: Remove -Wcast-align

Apparently gcc warns that GstMiniObject is not castable to
GstEvent/Message/Buffer due to them containing 64bit variables, even
though ARM hackers claim that those only need 4byte alignment. And as
long as gcc behaves that way, this warning is not very useful.

So we'll remove the warning until this problem is fixed.
Comment 3 Tim-Philipp Müller 2010-04-14 11:26:47 UTC
> (...) due to them containing 64bit variables, even
> though ARM hackers claim that those only need 4byte alignment. And as
> long as gcc behaves that way, this warning is not very useful.
> 
> So we'll remove the warning until this problem is fixed.

Seems to depend on the ABI used:
http://wiki.debian.org/ArmEabiPort#A64-bitdatatypealignment
Comment 4 Benjamin Otte (Company) 2010-04-14 12:56:29 UTC
Thanks for the link.
Is there a compiler flag to force objects to have "max" alignment? It might make sense to add that flag to GTypeInstance.
It's not a problem today because everyone uses g_type_create_instance() today exclusively which uses GSlice and that seems to magically get the alignment right.
Comment 5 Thiago Sousa Santos 2010-04-15 10:17:35 UTC
Created attachment 158799 [details] [review]
configure: Drop -Wcast-align

Patch for good
Comment 6 Thiago Sousa Santos 2010-04-15 10:19:33 UTC
Created attachment 158800 [details] [review]
configure: Drop -Wcast-align

Patch for -base
Comment 7 Thiago Sousa Santos 2010-04-15 10:21:20 UTC
Marking as blocker, this should go in the releases.
Comment 8 Tim-Philipp Müller 2010-04-15 10:29:36 UTC
> Is there a compiler flag to force objects to have "max" alignment? It might
> make sense to add that flag to GTypeInstance.

I thought __attribute__((aligned)) did that (there also seems to be a __BIGGEST_ALIGNMENT__ macro?). However, I'm not sure if it's wise to use that in a library header, since it may change depending on the compiler command line options AIUI. Maybe a specific alignment that's known to be good enough on all supported platforms will do (synced to whatever GSlice does). But in any case, adding it to GType and GTypeClass fixes most issues with type instance and class cast.

However, there are still other issues, esp. with GArray's g_array_free(FALSE) etc.
Comment 9 Benjamin Otte (Company) 2010-04-15 11:34:39 UTC
You can avoid the warning by doing an intermediate cast to gpointer, like so: (guint32 *) (gpointer) buffer->data - I've been doing that in Swfdec. And that should work fine for g_array_free() etc.

Those casts happen very often in plugins though (think 16bit audio), so I wouldn't even care to use the warning there. Not until we have a better solution for GST_BUFFER_DATA().
Comment 10 Tim-Philipp Müller 2010-04-22 08:20:32 UTC
Dropping severity, since we removed -Wcast-align. Can we close this bug? I am not sure it's worth keeping it open, at least not until GLib gets fixed.
Comment 11 Wim Taymans 2011-07-07 16:54:18 UTC
also in gst-ffmpeg, it caused compile problems on ARM

commit 3008de63e4b729cb7a4eda9829ff00db70ab8fca
Author: Wim Taymans <wim.taymans@collabora.co.uk>
Date:   Thu Jul 7 18:52:23 2011 +0200

    remove -Wcast-align
    
    See: https://bugzilla.gnome.org/show_bug.cgi?id=615698