[Webkit-unassigned] [Bug 43963] Avoid increasing required alignment of target type warning

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Aug 17 00:57:49 PDT 2010


https://bugs.webkit.org/show_bug.cgi?id=43963





--- Comment #9 from Gabor Loki <loki at webkit.org>  2010-08-17 00:57:49 PST ---
First of all almost every allocator endeavor to allocate an aligned memory range for an object, but the compilers do not know anything about the memory allocators. So, the alignment warnings can be safely ignored if reinterpret_cast is used on the beginning of the allocated object.

For example:
char* c = new char[1024]; // in most cases it is aligned to sizeof(int) bytes
unsigned* d = reinterpret_cast<unsigned*>(c); // Safe way
unsigned* d = reinterpret_cast<unsigned*>(&c[2]); // Bogus

> WebCore/platform/graphics/cairo/ImageBufferCairo.cpp lines 128 , 181 , 249: warning: cast from 'unsigned char*' to 'unsigned int*' increases required alignment of target type

128 and 249: I am not sure how Cairo allocates the data member of a cairo_image_surface structure, but I assume it is allocated as an RGBA container which can be an unsigned int array. It looks like a safe way to use reinterpret_cast here.

181: Fine

> WebCore/platform/graphics/cairo/ImageCairo.cpp:242: warning: cast from 'unsigned char*' to 'unsigned int*' increases required alignment of target type

242: same as above

> WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp:347: warning: cast from 'jpeg_error_mgr*' to 'WebCore::decoder_error_mgr*' increases required a    lignment of target type

347: Fine

> WebKit/gtk/webkit/webkitwebview.cpp:2972: warning: cast from 'GTypeInstance*' to 'GtkAdjustment*' increases required alignment of target type
> WebKit/gtk/webkit/webkitwebview.cpp:2973: warning: cast from 'GTypeInstance*' to 'GtkAdjustment*' increases required alignment of target type
> 

I cannot found them in the trunk.

> JavaScriptCore/pcre/pcre_compile.cpp:2592: warning: cast from 'char*' to 'JSRegExp*' increases required alignment of target type

It will be fine if the StdLibExtras.h is modified.

I will create a patch for you which can tested in release and debug mode as well. ;)

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list