[3.3/3.4] wrong handling of "extern const" variables
Gunther Nikl
gni@gecko.de
Wed Aug 20 16:11:00 GMT 2003
Hello!
The following patch which was installed at 2003-04-07 to fix opt/8634
http://gcc.gnu.org/ml/gcc-patches/2002-12/msg00533.html
exhibits a problem in the handling of "extern const" variables.
--- foo1.c ---
const char bar[] = "haha";
--- foo1.c ---
Compiling that with 3.3 sets RTX_UNCHANGING_P in explow.c/maybe_set_unchanging
for bar because TREE_STATIC is true. Since RTX_UNCHANGING_P is true, bar is
placed in the text section on my target.
--- foo2.c ---
extern const char bar[];
const char *foo(void)
{
return bar;
}
--- foo2.c ---
RTX_UNCHANGING_P isn't set in explow.c/maybe_set_unchanging for bar because
TREE_STATIC is false. Thus bar is assumed to be in the data section on my
target.
This looks like a bug but I don't know what excatly the bug is.
Regards,
Gunther Nikl
More information about the Gcc
mailing list