http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56699



             Bug #: 56699

           Summary: Failed for sizeof (non-static member) in lambda

                    expression

    Classification: Unclassified

           Product: gcc

           Version: 4.8.0

            Status: UNCONFIRMED

          Severity: normal

          Priority: P3

         Component: c++

        AssignedTo: unassig...@gcc.gnu.org

        ReportedBy: frankhb1...@gmail.com





Here are the minimal testcases:



Case 1:



struct A

{

    int a;

};



struct T

{

    int x;



    T() : x([]{

        sizeof(::A::a);

        return 0;

    }())

    {}

};



Case 2:



struct A

{

    int a;

};



void f()

{

    []{sizeof(A::a);};

}



Tested at coliru.stacked-crooked.com (g++ -v shows it's a x86-64 linux host):



Case 1:

$ g++-4.8 -fsyntax-only -std=c++11 main.cpp

main.cpp: In lambda function:

main.cpp:11:15: error: type 'A' is not a base type for type 'T'

   sizeof(::A::a);

               ^

Case 2:

$ g++-4.8 -fsyntax-only -std=c++11 main.cpp

main.cpp: In lambda function:

main.cpp:10:15: internal compiler error: Segmentation fault

  []{sizeof(A::a);};

               ^



I have exactly the same errors for both cases using mingw-builds

4.8.0(i686-w64-mingw32) compiled today from sf.net on my Win7 x64 host.



>From some others, I've heard Case 1 is accepted by g++-4.8 compiled just now on

Ubuntu12.04, but the ICE still exists for Case 2.



G++ 4.7 accepts both cases.

Reply via email to