Dear all, I would like to post a bug report for the GNU C/C++ compiler 3.3-e500.
We use the compiler to generate code for a PowerPC processor. Used invokation line for the GNU C++ compiler: ccppc -c -x c++ -ansi -Wall -Werror -mcpu=8540 -fverbose-asm -mbig -fmerge-templates -mmultiple -mno-string -mstrict-align -O3 -fno-exceptions -fno-rtti -fno-builtin-printf -I<different include paths> -D<differen #define's> X.CPP -oX.O // file X.CPP inline const char* getIDString () { return "XYZ"; } const char* getID () { return getIDString(); } The code above compiles fine. The compiler emits code which places the string literal "XYZ" in the section .rodata (see below). This means that every translation unit which uses the funtion getIDString contains a different "XYZ" object. Note: compiler option -fmerge-templates is enabled. I think this behavior runs afoul 7.1.2/4: "A string literal in an extern inline function is the same object in different translation units." For further background see also DR 397 (http://open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#397). Kind regards W. Roehrl =========================================================================== Generated code for file X.CPP: .file "x.CPP" # rs6000/powerpc options: -mcpu=8540 -msdata=data # GNU C++ version 3.3-e500 20030421 (Wind River) (powerpc-wrs-vxworks) # compiled by GNU C version 3.2.2. # GGC heuristics: --param ggc-min-expand=47 --param ggc-min-heapsize=32684 # options passed: -I. -ID:\\GNU_NG\\target\\h # -ID:\\GNU_NG\\target\\h\\types -ID:\\GNU_NG\\target\\h\\arch\\ppc # -iprefix -D__GNUC__=3 -D__GNUC_MINOR__=3 -D__GNUC_PATCHLEVEL__=0 # -DCPU=PPC85XX -DTOOL_FAMILY=gnu -DTOOL=gnu -D__GNUG__=3 -mcpu=8540 -mbig # -mmultiple -mno-string -mstrict-align -ansi -auxbase-strip -O3 -Wall # -Werror -ansi -fverbose-asm -fmerge-templates -fno-exceptions -fno-rtti # -fno-builtin-printf -ox.ASS # options enabled: -fdefer-pop -fomit-frame-pointer # -foptimize-sibling-calls -fcse-follow-jumps -fcse-skip-blocks # -fexpensive-optimizations -fthread-jumps -fstrength-reduce -fpeephole # -fforce-mem -ffunction-cse -fkeep-static-consts -fcaller-saves # -freg-struct-return -fgcse -fgcse-lm -fgcse-sm -floop-optimize # -fcrossjumping -fif-conversion -fif-conversion2 -frerun-cse-after-loop # -frerun-loop-opt -fdelete-null-pointer-checks -fschedule-insns # -fschedule-insns2 -fsched-interblock -fsched-spec -fbranch-count-reg # -freorder-blocks -freorder-functions -frename-registers # -fcprop-registers -fcommon -fverbose-asm -fregmove # -foptimize-register-move -fargument-alias -fstrict-aliasing # -fmerge-constants -fzero-initialized-in-bss -fident -fpeephole2 # -fguess-branch-probability -fmath-errno -ftrapping-math -mpowerpc # -mpowerpc-gfxopt -mnew-mnemonics -mmultiple -mno-multiple -mno-string # -msched-prolog -msched-epilog -mstrict-align -meabi -mcpu=8540 # -mcall-sysv -msdata=data .section .rodata .align 2 .LC0: .string "XYZ" .section ".text" .align 2 .globl _Z5getIDv .type _Z5getIDv, @function _Z5getIDv: lis 4,[EMAIL PROTECTED] la 3,[EMAIL PROTECTED](4) blr .size _Z5getIDv, .-_Z5getIDv .ident "GCC: (GNU) 3.3-e500 20030421 (Wind River)" -- Summary: string literals in global inline functions Product: gcc Version: 3.3 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: wolfgang dot roehrl at de dot gi-de dot com CC: gcc-bugs at gcc dot gnu dot org GCC build triplet: sparc-sun-solaris2.5.1 GCC host triplet: i386-pc-mingw32 GCC target triplet: powerpc-wrs-vxworks http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22459