Red Hat Bugzilla – Bug 24685
g++ 2.96 generates illegal operands in assembly file
Last modified: 2007-03-26 23:39:38 EDT
My environment : gcc version 2.96 20000731 (Red Hat Linux 7.0) RedHat Linux 7.0, Pentium II binutils-2.10.1.0.2-1 gcc-c++-2.96-69 The g++ compiler seems to generate an illegal intermediate assembly file. The command line and compiler output are : [johaenni@lslpc6 ipa]$ g++ -D_SGI_SOURCE -D_LANGUAGE_C_PLUS_PLUS -funsigned-char -D__GNU_BUG_WORKAROUND -D_NOTHREADS -c -D__MIPS_AND_IA64_ELF_H -DTARG_IA64 -D_NEW_SYMTAB -D_MERGE_SUMMARY_ST_IDX_=1 -DBACK_END -DSTD_MONGOOSE_LOC='"/usr/lib32/cmplrs"' -D_SUPPORT_IPA -D_MULTIGOT -D_NEW_SYMTAB -D_MERGE_SUMMARY_ST_IDX_=1 -DBACK_END -DSTD_MONGOOSE_LOC='"/usr/lib32/cmplrs"' -D_SUPPORT_IPA -DMONGOOSE_BE -I../../ipa/common -I../../ipa/local -I../../ipa/main/optimize -I../../ipa/main/analyze -I../../be/lno -I../../be/com -I../../common/com -I../../be/region -I../../be/opt -I../../common/com/ia64 -I../../common/util -I../../fake_ld/common -I../../fake_ld -I../be -I../include/libelf -I../include -O0 -D_MIPSEL -D_LONGLONG -D_MIPS_SZINT=32 -D_MIPS_SZPTR=32 -D_MIPS_SZLONG=32 -MD ../../ipa/common/ipc_dst_merge.cxx -o ipc_dst_merge.o In file included from ../../be/com/fb_whirl.h:67, from ../../ipa/local/ipl_summary.h:76, from ../../ipa/main/analyze/ipa_cg.h:65, from ../../ipa/common/ipc_dst_merge.cxx:51: ../../common/com/fb_info.h:142:2: warning: multi-line comment ../../common/com/fb_info.h:145:2: warning: multi-line comment /tmp/ccDxbw5Q.s: Assembler messages: /tmp/ccDxbw5Q.s:165: Error: invalid character '=' in operand 1 /tmp/ccDxbw5Q.s:446: Error: invalid character '=' in operand 1 /tmp/ccDxbw5Q.s:518: Error: invalid character '=' in operand 1 /tmp/ccDxbw5Q.s:796: Error: invalid character '=' in operand 1 /tmp/ccDxbw5Q.s:859: Error: invalid character '=' in operand 1 /tmp/ccDxbw5Q.s:1171: Error: invalid character '=' in operand 1 /tmp/ccDxbw5Q.s:1244: Error: invalid character '=' in operand 1 /tmp/ccDxbw5Q.s:1328: Error: invalid character '=' in operand 1 /tmp/ccDxbw5Q.s:11201: Error: Rest of line ignored. First ignored character is `!'. /tmp/ccDxbw5Q.s:11202: Error: ignoring unrecognized symbol type "" /tmp/ccDxbw5Q.s:11202: Error: Rest of line ignored. First ignored character is `!'. /tmp/ccDxbw5Q.s:11203: Error: invalid character '!' in mnemonic /tmp/ccDxbw5Q.s:11232: Error: expected comma after name `operator' in .size directive /tmp/ccDxbw5Q.s:11232: Error: Rest of line ignored. First ignored character is `!'. /tmp/ccDxbw5Q.s:11670: Warning: missing operand; zero assumed /tmp/ccDxbw5Q.s:12129: Error: Rest of line ignored. First ignored character is `<'. /tmp/ccDxbw5Q.s:12130: Error: ignoring unrecognized symbol type "" /tmp/ccDxbw5Q.s:12130: Error: Rest of line ignored. First ignored character is `<'. /tmp/ccDxbw5Q.s:12131: Error: invalid character '<' in mnemonic /tmp/ccDxbw5Q.s:12165: Error: expected comma after name `operator' in .size directive /tmp/ccDxbw5Q.s:12165: Error: Rest of line ignored. First ignored character is `<'. [johaenni@lslpc6 ipa]$ I've looked at the assembly file and have found such lines: .size __stl_next_prime__FUl,.Lfe209-__stl_next_prime__FUl .section .gnu.linkonce.t.operator!=,"ax",@progbits .align 4 .weak operator!= .type operator!=,@function operator!=: or call operator!= I've created a proprocessed file ipc_dst_merge.ii. You can find it at http://lslwww.epfl.ch/~johaenni/bugzilla/ipc_dst_merge.ii.bz2 (I don't know how to attach a file to a bug report...) How to repeat the bug ? Just type 'g++ ipc_dst_merge.ii'.
Created attachment 8068 [details] Preprocessed C++ file generating a compilation error.
This is primarily a bug in dwarf_DST_mem.h, I've reduced your testcase into extern "C" { typedef struct _baz { int a; } baz; extern const baz z; inline bool operator!=(const baz& x, const baz& y) { return x.a != y.a; } }; void foo(); void bar(baz x) { if (x != z) foo(); } . operator!= should definitely not be declared with "C" linkage. I'll ask our C++ language lawyers whether they think there is required diagnostic on this (I haven't found anything in the standard), but I don't think C++ is required to use "C++" linkage for things which cannot be in "C" linkage but are declared so.
Fixed in gcc-c++-2.96-72 and above.
*** Bug 39170 has been marked as a duplicate of this bug. ***