Bug 47851 - [4.6 Regression] [C++0x] Incorrect decltype result for conditional operator
Summary: [4.6 Regression] [C++0x] Incorrect decltype result for conditional operator
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: 4.6.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-22 17:55 UTC by Michel Morin
Modified: 2011-03-01 23:28 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Test case (287 bytes, application/octet-stream)
2011-02-22 17:55 UTC, Michel Morin
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michel Morin 2011-02-22 17:55:08 UTC
Created attachment 23436 [details]
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`.)
Comment 1 Paolo Carlini 2011-02-22 18:04:47 UTC
Let's ask Jason to have a look.
Comment 2 Jason Merrill 2011-03-01 22:44:41 UTC
Author: jason
Date: Tue Mar  1 22:44:35 2011
New Revision: 170601

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=170601
Log:
	PR c++/47851
	* call.c (standard_conversion): Provide requested cv-quals on
	class rvalue conversion.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/decltype25.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/call.c
    trunk/gcc/testsuite/ChangeLog
Comment 3 Jason Merrill 2011-03-01 22:47:47 UTC
Fixed (so that both are Type const).
Comment 4 Paolo Carlini 2011-03-01 23:28:45 UTC
Thanks!