This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/47851] New: [4.6 Regression] [C++0x] Incorrect decltype result for conditional operator
- From: "mimomorin at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 22 Feb 2011 17:55:13 +0000
- Subject: [Bug c++/47851] New: [4.6 Regression] [C++0x] Incorrect decltype result for conditional operator
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47851
Summary: [4.6 Regression] [C++0x] Incorrect decltype result for
conditional operator
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: mimomorin@gmail.com
Created attachment 23436
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=23436
Test case
Suppose we have a code
struct Type {};
typedef Type const ConstType;
struct ConvertibleToType {
operator Type&() { return *reinterpret_cast<Type*>(this); }
};
Then expression `true ? ConvertibleToType() : ConstType()` has type `Type`.
But `decltype(true ? ConvertibleToType() : ConstType())` is `Type const`.
Note that, in gcc 4.5, both the type of the expression and its `decltype` are
`Type`.
(In clang TOT, both are `Type const`.)