Bug#398316: gcc-4.1: Apparent inline function expansion bug on ARM
On Mon, Nov 13, 2006 at 09:49:21AM +0100, Falk Hueffner wrote:
> Hi,
>
> this looks like an aliasing violation to me. bb->list, which is of
> type __u32*, is accessed via an lvalue of type void*, which is not
> compatible. Does the problem go away with -fno-strict-aliasing?
Good point, thanks. Yes, it does go away when I use
-fno-strict-aliasing.
Interestingly, I didn't get nary a peep when I enabled tried running
gcc "-O2 -Wstrict-aliasing=2". I would have expected gcc to have
complained about this, but apparently not.
Do you think the problem is with the call to ext2fs_get_mem:
retval = ext2fs_get_mem(bb->size * sizeof(blk_t), &bb->list);
where I pass a __u32* to ext2fs_get_mem as a void*?
Or the implementation where I play games with void** and void*:
_INLINE_ errcode_t ext2fs_get_mem(unsigned long size, void *ptr)
{
void **pp = (void **)ptr;
*pp = malloc(size);
...
I tried changing the function signature of ext2fs_get_mem() to be:
_INLINE_ errcode_t ext2fs_get_mem(unsigned long size, char *ptr)
... since according to the spec storing through a char* is supposed to
be OK, but that didn't seem to fix the problem. I'd really hate to be
forced to change the function signature to something like this:
_INLINE_ void * ext2fs_get_mem2(unsigned long size, errcode_t *retval)
just to get around these !@#! type-punning rules, but I can't think of
anything else that might work. Is there anything you might suggest?
Thanks, regards,
- Ted
Reply to: