-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Reapply "[Clang][CWG1815] Support lifetime extension of temporary created by aggregate initialization using a default member initializer" #97308
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
e6ee9be
dbe5cd3
58c947b
c8b8169
0a8214c
ad08b40
9ad4dcb
6e0c524
077753f
d3284e6
efbf235
3d425bc
8c3c584
a765b6d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
yronglin marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -206,19 +206,28 @@ namespace cwg1814 { // cwg1814: yes | |
#endif | ||
} | ||
|
||
namespace cwg1815 { // cwg1815: no | ||
namespace cwg1815 { // cwg1815: 19 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems to be the case, yeah. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, I missed this! I'll fix it. Thank you for point out this. |
||
#if __cplusplus >= 201402L | ||
// FIXME: needs codegen test | ||
struct A { int &&r = 0; }; // #cwg1815-A | ||
struct A { int &&r = 0; }; | ||
A a = {}; | ||
// since-cxx14-warning@-1 {{lifetime extension of temporary created by aggregate initialization using a default member initializer is not yet supported; lifetime of temporary will end at the end of the full-expression}} FIXME | ||
// since-cxx14-note@#cwg1815-A {{initializing field 'r' with default member initializer}} | ||
|
||
struct B { int &&r = 0; }; // #cwg1815-B | ||
// since-cxx14-error@-1 {{reference member 'r' binds to a temporary object whose lifetime would be shorter than the lifetime of the constructed object}} | ||
// since-cxx14-note@#cwg1815-B {{initializing field 'r' with default member initializer}} | ||
// since-cxx14-note@#cwg1815-b {{in implicit default constructor for 'cwg1815::B' first required here}} | ||
B b; // #cwg1815-b | ||
|
||
#if __cplusplus >= 201703L | ||
struct C { const int &r = 0; }; | ||
constexpr C c = {}; // OK, since cwg1815 | ||
static_assert(c.r == 0); | ||
|
||
constexpr int f() { | ||
A a = {}; // OK, since cwg1815 | ||
return a.r; | ||
} | ||
static_assert(f() == 0); | ||
#endif | ||
#endif | ||
} | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.