Bug 86475 - CWG 1550
Summary: CWG 1550
Status: RESOLVED DUPLICATE of bug 64372
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 8.1.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2018-07-11 00:34 UTC by zhonghao
Modified: 2021-07-23 00:06 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2018-07-24 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description zhonghao 2018-07-11 00:34:55 UTC
I looked around to see if a bug was already filed on this and couldn't find one.

CWG 1550, passed in Bristol, changes the value category of the result of a conditional operator when one operand is an lvalue and the other is a throw-expression:

* The second or the third operand (but not both) is a (possibly parenthesized) throw-expression (15.1); the result is of the type and value category of the other.

Here is a test, that should compile in C++:

struct X
{
    int i_;
    bool b_;

    int& test() {return b_ ? i_ : throw 1;}
};

Current behavior is:

 error: cannot bind non-const lvalue reference of type 'int&' to an rvalue of type 'int'
  int& test() {return b_ ? i_ : throw 1;}
                      ~~~^~~~~~~~~~~~~~

                        ^~~~~~~~~~~~~~~~~
1 error generated.

I tried clang++. It accepts the code.
Comment 1 Andrew Pinski 2021-07-23 00:06:04 UTC
This is a dup of bug 64372.

*** This bug has been marked as a duplicate of bug 64372 ***