[Bug c/39383] sizeof object with zero-length array ignores initializer

anmol at freescale dot com gcc-bugzilla@gcc.gnu.org
Fri Apr 17 22:39:00 GMT 2009



------- Comment #10 from anmol at freescale dot com  2009-04-17 22:39 -------
I am working on this problem and see that for generic ELF OS's,
defining ASM_DECLARE_OBJECT_NAME (gcc/config/elfos.h) to use the
size of the initializer (as against the size of the type) to emit
the true size in the .size directive results in the following code
being emitted for the submitted example:

        .type   f1, @object
        .size   f1, 16
f1:
        .long   1
        .long   2
        .long   3
        .long   4
        .section        .rodata

I am currently regression testing my fix (and plan
on submitting the patch for the generic ELF OS case
(assuming that this is the right approach to take
here)).

However, I am not sure if the same change will be
needed in ASM_FINISH_DECLARE_OBJECT as well? 
rest_of_decl_compilation in gcc/passes.c seems to
suggest that this macro is used for tentative
definitions - in which case there would be no 
initializer and that seems to suggest that no change
would be needed (using the size of the type would
be the right thing to do). But in the GCC Internals
Manual, Ch. 17 Sec. 17.21.4 Output and Generation of
Labels - the description suggests that a change is
needed in this macro as well. (Kindly advise, and I
shall incorporate).

Thank you.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39383



More information about the Gcc-bugs mailing list