Bug 47068 - [C++0x] internal compiler error on decltype(~ expression)
Summary: [C++0x] internal compiler error on decltype(~ expression)
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.4.3
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2010-12-27 16:20 UTC by Brent Spillner
Modified: 2011-01-01 00:15 UTC (History)
1 user (show)

See Also:
Host: Linux (Ubuntu 10.10, x86 32-bit)
Target: Same (Ubuntu Linux 10.10, x86 32-bit)
Build:
Known to work:
Known to fail:
Last reconfirmed: 2010-12-27 16:26:36


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Brent Spillner 2010-12-27 16:20:14 UTC
The declaration

template <class T> struct broken {
  int member;
  typedef decltype(~ member) gcc_crashes_here;
};

generates the error message "internal compiler error: in lookup_member, at cp/search.c:1200, Please submit a full bug report" when compiled with g++ 4.4.3 (with -std=c++0x, naturally.)

Similar code compiles without errors or warnings if any of the following transformations are applied:
   - A literal expression (e.g. "~ 0L") is substituted for "~ member"
   - The operators !, &, -, +, or * (when member is changed to a pointer type) are used instead of ~
   - The struct is not templated
   - The typedef is declared in a free function (even a templated free function) rather than a class or struct
   - decltype is replaced by typeof and the code is compiled without -std=c++0x

Unfortunately I'm traveling at the moment and can't easily test on other gcc versions.
Comment 1 Paolo Carlini 2010-12-27 16:26:04 UTC
I can reproduce it with current mainline.
Comment 2 Jason Merrill 2010-12-28 15:34:44 UTC
Looking.
Comment 3 Jason Merrill 2010-12-29 02:17:51 UTC
Author: jason
Date: Wed Dec 29 02:17:47 2010
New Revision: 168309

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=168309
Log:
	PR c++/47068
	* semantics.c (finish_id_expression): Don't note non-names
	as being used in the class.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/decltype24.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/semantics.c
    trunk/gcc/testsuite/ChangeLog
Comment 4 Jason Merrill 2011-01-01 00:15:01 UTC
Fixed.