Bug 56699 - [4.8/4.9 regression] Failed for sizeof (non-static member) in lambda expression
Summary: [4.8/4.9 regression] Failed for sizeof (non-static member) in lambda expression
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.8.0
: P3 normal
Target Milestone: ---
Assignee: Jason Merrill
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-03-23 16:06 UTC by frankhb1989
Modified: 2013-03-27 01:17 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 4.7.2
Known to fail: 4.8.0
Last reconfirmed: 2013-03-25 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description frankhb1989 2013-03-23 16:06:34 UTC
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.
Comment 1 frankhb1989 2013-03-23 16:29:09 UTC
Sorry, something was wrong, g++-4.8 on Ubuntu should also reject Case 1 in fact.
Comment 2 Paolo Carlini 2013-03-27 01:17:34 UTC
Fixed mainline and 4.8.1.