Bug 24685

Summary: g++ 2.96 generates illegal operands in assembly file
Product: [Retired] Red Hat Linux Reporter: Jacques-Olivier Haenni <haenni>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED RAWHIDE QA Contact: David Lawrence <dkl>
Severity: medium Docs Contact:
Priority: high    
Version: 7.0CC: haenni
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2001-01-23 15:46:00 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Preprocessed C++ file generating a compilation error. none

Description Jacques-Olivier Haenni 2001-01-23 13:30:40 UTC
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'.

Comment 1 Jacques-Olivier Haenni 2001-01-23 13:32:58 UTC
Created attachment 8068 [details]
Preprocessed C++ file generating a compilation error.

Comment 2 Jakub Jelinek 2001-01-23 15:45:57 UTC
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.

Comment 3 Jakub Jelinek 2001-02-05 21:03:15 UTC
Fixed in gcc-c++-2.96-72 and above.

Comment 4 Jakub Jelinek 2001-05-05 17:01:36 UTC
*** Bug 39170 has been marked as a duplicate of this bug. ***