Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

segmentation fault while compiling template class with inner class and enum #12435

Closed Quuxplusone closed 12 years ago

Quuxplusone commented 12 years ago
Bugzilla Link PR12317
Status RESOLVED FIXED
Importance P normal
Reported by Martin Richtarsky (clang@martinien.de)
Reported on 2012-03-20 14:52:12 -0700
Last modified on 2012-03-21 22:37:25 -0700
Version trunk
Hardware PC Linux
CC dgregor@apple.com, efriedma@quicinc.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
Fixed by commit(s)
Attachments clang_crash.cpp (214 bytes, text/plain)
clang_crash-FOi1BT.ii (341 bytes, application/octet-stream)
clang_crash-FOi1BT.sh (2015 bytes, application/octet-stream)
Blocks
Blocked by
See also
Created attachment 8243
source file

Hi clang developers,

while compiling the following code I get a segfault.

clang_crash.cpp:

template <class A>
class Outer
{
public:
  class Inner
  {
  public:
    //Inner();
    enum {
      VAL1 = 1
    };
    //static const int VAL1=1;

    char b[100-VAL1];
  };

  Inner inner;
};

Outer<int> outer;

/usr> clang++ clang_crash.cpp
clang: error: unable to execute command: Segmentation fault

Some observations:
- removing the enum and uncommenting the "static const int VAL1" makes it work
- uncommenting the Inner() constructor causes about 20 identical errors to be
printed out:

  clang_crash.cpp:8:5: error: constructor cannot be redeclared
      Inner();

Afterwards, clang still segfaults.
- when the outer class isn't a template it also works

I have attached the source, preprocessed source and the run script.

clang version 3.1 (trunk 153100)
Target: x86_64-unknown-linux-gnu
Thread model: posix

Could you have a look please?

Best regards,
Martin
Quuxplusone commented 12 years ago

Attached clang_crash.cpp (214 bytes, text/plain): source file

Quuxplusone commented 12 years ago

Attached clang_crash-FOi1BT.ii (341 bytes, application/octet-stream): preprocessed source

Quuxplusone commented 12 years ago

Attached clang_crash-FOi1BT.sh (2015 bytes, application/octet-stream): run script

Quuxplusone commented 12 years ago

Fixed in r153236.