https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65954

            Bug ID: 65954
           Summary: gcc segfaults on the following input with a syntax
                    error
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: federl at gmail dot com
  Target Milestone: ---

g++ 4.8.2 on Ubuntu 14.04.2 LTS, 64bit throws a segmentation fault on the input
below (it contains a small typo Cicle instead of Circle). BTW, fixing the typo
also fixes the segfault...

$ cat test.cpp

namespace carta {
    namespace lib {
        class Shape {
        public:
            enum class Type { Circle, Square };
        };
    }
}

int main( int, char **)
{
    auto x = carta::lib::Shape::Type::Circle;
    carta::lib::Shape shape;
    carta::lib::Shape::Type y;
    y = shape.Type::Cicle;
    return 0;
}

$ g++ -std=c++11 test.cpp

test.cpp: In function ‘int main(int, char**)’:
test.cpp:15:21: internal compiler error: Segmentation fault
     y = shape.Type::Cicle;
                     ^
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
Preprocessed source stored into /tmp/cc94vBRp.out file, please attach this to
your bugreport.

$ cat /tmp/cc94vBRp.out

// /usr/lib/gcc/x86_64-linux-gnu/4.8/cc1plus -quiet -imultiarch
x86_64-linux-gnu -D_GNU_SOURCE test.cpp -quiet -dumpbase test.cpp
-mtune=generic -march=x86-64 -auxbase test -std=c++11 -fstack-protector
-Wformat -Wformat-security -o - -frandom-seed=0
# 1 "test.cpp"
# 1 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 1 "<command-line>" 2
# 1 "test.cpp"
namespace carta {
    namespace lib {
 class Shape {
 public:
     enum class Type { Circle, Square };
 };
    }
}

int main( int, char **)
{
    auto x = carta::lib::Shape::Type::Circle;
    carta::lib::Shape shape;
    carta::lib::Shape::Type y;
    y = shape.Type::Cicle;
    return 0;
}

Reply via email to