Bug 24248 - [4.0 Regression] Segmentation fault on valid code w/ -O2 -finline-functions
Summary: [4.0 Regression] Segmentation fault on valid code w/ -O2 -finline-functions
Status: RESOLVED DUPLICATE of bug 22252
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.0.2
: P2 normal
Target Milestone: 4.0.3
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on: 22252
Blocks:
  Show dependency treegraph
 
Reported: 2005-10-07 01:01 UTC by Mark Loeser
Modified: 2005-10-18 13:03 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.1.0
Known to fail: 4.0.3
Last reconfirmed: 2005-10-07 03:46:32


Attachments
Preprocessed source that causes ICE (77.59 KB, text/plain)
2005-10-07 01:02 UTC, Mark Loeser
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Loeser 2005-10-07 01:01:48 UTC
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-4.0.2/configure --prefix=/root/bin/ --disable-multilib --enable-languages=c,c++
Thread model: posix
gcc version 4.0.2

Output of compile:
x86_64-pc-linux-gnu-g++ -DHAVE_CONFIG_H -I. -I. -I.. -I../include -I../generic -mtune=opteron -march=opteron -O2 -fomit-frame-pointer -ftracer -pipe -fweb -ftree-vectorize -finline-functions -c ArcEngine.cxx -MT ArcEngine.lo -MD -MP -MF .deps/ArcEngine.TPlo  -fPIC -DPIC -o .libs/ArcEngine.lo
../include/Attribute.h:356: warning: inline function 'OpenSP::AttributeDefinitionList::~AttributeDefinitionList()' used but never defined
../include/Notation.h:27: warning: inline function 'virtual OpenSP::Notation::~Notation()' used but never defined
../include/Dtd.h:30: warning: inline function 'OpenSP::Dtd::~Dtd()' used but never defined
../include/Lpd.h:149: warning: inline function 'virtual OpenSP::ComplexLpd::~ComplexLpd()' used but never defined
../include/Lpd.h:98: warning: inline function 'virtual OpenSP::LinkSet::~LinkSet()' used but never defined
../include/Sd.h:28: warning: inline function 'OpenSP::Sd::~Sd()' used but never defined
../include/CharsetInfo.h:22: warning: inline function 'OpenSP::CharsetInfo::~CharsetInfo()' used but never defined
../include/UnivCharsetDesc.h:22: warning: inline function 'OpenSP::UnivCharsetDesc::~UnivCharsetDesc()' used but never defined
../include/CharsetDecl.h:71: warning: inline function 'OpenSP::CharsetDecl::~CharsetDecl()' used but never defined
../include/Syntax.h:28: warning: inline function 'OpenSP::Syntax::~Syntax()' used but never defined
../include/Entity.h:272: warning: inline function 'virtual OpenSP::EntityOrigin::~EntityOrigin()' used but never defined
../include/Location.h:130: warning: inline function 'OpenSP::InputSourceOrigin::~InputSourceOrigin()' used but never defined
../include/Markup.h:41: warning: inline function 'OpenSP::Markup::~Markup()' used but never defined
../include/ElementType.h:30: warning: inline function 'OpenSP::ElementDefinition::~ElementDefinition()' used but never defined
../include/Ptr.cxx:23: warning: inline function 'virtual OpenSP::InputSourceOrigin::~InputSourceOrigin()' used but never defined
../include/Text.h:21: warning: inline function 'OpenSP::TextItem& OpenSP::TextItem::operator=(const OpenSP::TextItem&)' used but never defined
../include/ContentToken.h:22: warning: inline function 'OpenSP::Transition::~Transition()' used but never defined
Recognizer.h:24: warning: inline function 'OpenSP::Recognizer::~Recognizer()' used but never defined
../include/Message.h:132: warning: inline function 'OpenSP::OpenElementInfo::~OpenElementInfo()' used but never defined
../include/ContentToken.h:309: warning: inline function 'OpenSP::CompiledModelGroup::~CompiledModelGroup()' used but never defined
../include/Attribute.h:460: warning: inline function 'OpenSP::Attribute::~Attribute()' used but never defined
../include/Text.h:21: warning: inline function 'OpenSP::TextItem::TextItem(const OpenSP::TextItem&)' used but never defined
../include/Text.h:21: warning: inline function 'OpenSP::TextItem::~TextItem()' used but never defined
../include/Lpd.h:27: warning: inline function 'OpenSP::ResultElementSpec::~ResultElementSpec()' used but never defined
../include/CharsetDecl.h:49: warning: inline function 'OpenSP::CharsetDeclSection::~CharsetDeclSection()' used but never defined
../include/ContentToken.h:117: warning: inline function 'virtual OpenSP::ModelGroup::~ModelGroup()' used but never defined
../include/ContentToken.h:196: warning: inline function 'virtual OpenSP::LeafContentToken::~LeafContentToken()' used but never defined
../include/ContentToken.h:182: warning: inline function 'OpenSP::AndInfo::~AndInfo()' used but never defined
../include/CharsetDecl.h:20: warning: inline function 'OpenSP::CharsetDeclRange::~CharsetDeclRange()' used but never defined
../include/Lpd.h:93: warning: inline function 'OpenSP::SourceLinkRuleResource::~SourceLinkRuleResource()' used but never defined
../include/Lpd.h:71: warning: inline function 'OpenSP::SourceLinkRule::~SourceLinkRule()' used but never defined
x86_64-pc-linux-gnu-g++: Internal error: Segmentation fault (program cc1plus)
Please submit a full bug report.
See <URL:http://bugs.gentoo.org/> for instructions.
{standard input}: Assembler messages:
{standard input}:1275: Warning: end of file not at end of a line; newline inserted

The ICE only happens with -O2 -finline-functions (or anything including those)
Comment 1 Mark Loeser 2005-10-07 01:02:14 UTC
Created attachment 9914 [details]
Preprocessed source that causes ICE
Comment 2 Andrew Pinski 2005-10-07 02:01:48 UTC
../include/InternalInputSource.h:37: error: extra qualification ‘OpenSP::InternalInputSource::’ on member ‘asInternalInputSource’ ignored
Comment 3 Andrew Pinski 2005-10-07 02:08:50 UTC
After fixing that error, the mainline does not segfault, the 4.0 branch still does.

Reducing.
Comment 4 Andrew Pinski 2005-10-07 02:16:54 UTC
I am starting to think this is a front-end bug.  Removing all lines begining with ^# "fixes" the ICE.
Comment 5 Andrew Pinski 2005-10-07 02:19:22 UTC
This looks like another "pragma interface" bug.
Comment 6 Andrew Pinski 2005-10-07 02:21:00 UTC
I am starting to think this is a dup of bug 22252 because of the diagnostic we get.
Comment 7 Mark Loeser 2005-10-07 03:45:17 UTC
Adding those patches into gcc-4.0.2 seems to resolve the problem.
Comment 8 Andrew Pinski 2005-10-07 03:46:32 UTC
Confirmed, reduced testcase:
typedef __SIZE_TYPE__ size_t;
struct Allocator { };
template<class T> struct  Ptr {     ~Ptr();     T *ptr_;  };
template<class T> struct ConstPtr : private Ptr<T> {     ConstPtr(const Ptr<T> &p);  };
template<class T> Ptr<T>::~Ptr() {     delete ptr_;  }
#pragma interface
struct  AttributeDefinitionList {     ConstPtr<AttributeDefinitionList> prev_;  };
struct  Dtd {     Ptr<AttributeDefinitionList> implicitElementAttributeDef_;  };
struct  EndElementEvent {     void *operator new(size_t sz, Allocator &alloc);     EndElementEvent(const ConstPtr<Dtd> &);  };
struct  ArcProcessor {     void processEndElement(Allocator &);     Ptr<Dtd> metaDtd_;   };
void ArcProcessor::processEndElement(Allocator &alloc) {     new (alloc) EndElementEvent( metaDtd_);   }
Comment 9 Volker Reichelt 2005-10-17 23:54:54 UTC
Shorter testcase (ICEs with -O):

===============================================================
#pragma interface
template<typename T> struct A { T *p; ~A() { delete p; } };
template<typename T> struct B : A<T> { B(const A<T>&); };
struct C { B<C> b; C(const B<C>&); };
void foo() { new C(A<C>()); }
===============================================================
Comment 10 Andrew Pinski 2005-10-18 12:43:17 UTC

*** This bug has been marked as a duplicate of 22252 ***