Repository navigation
Commit 78f95ec
Apply Core issue 616 when emulating GCC 9+ and Clang 4+ [GH #90]
Under Core issue 616, selecting a member of a class prvalue yields an
xvalue, and binding a reference to it extends the lifetime of the whole
temporary. GNU and Clang modes kept the C++11 rule (a prvalue), so
const int &r = A().b;
bound to a copy of the member and destroyed A() at the end of the
full-expression. GCC 9 and Clang 4 implement the issue, so cmd_line.c now
enables selection_from_prvalue_is_xvalue when emulating those versions or
later. This reapplies the change backed out for EDGcpfe/29032.
That change regressed Clang's SemaCXX/constant-expression-cxx2a because,
for "." and ".*" on a class prvalue, the interpreter marked the whole
prvalue as initialized (eok_dot_field and eok_pm_field in interpret.c).
Since C++20 a constexpr constructor can leave members uninitialized, so
"Y(0,0).z1.n" folded to an indeterminate value instead of being diagnosed.
The marking is removed; the previous commit fixed the one case where the
per-subobject state was incomplete. The same bug already affected strict
C++20 mode ("static_assert(W().n == 0);" was accepted).
is_address_of_auto_object (exprutil.c) now looks through such an xvalue to
the class prvalue, so returning a pointer into the temporary (e.g.,
"return &static_cast<const int &>(A().b);") still warns; "return A().b;"
is already diagnosed through is_glvalue_for_auto_object_or_temp_subobject.
The traverse_addressing_subtree comments (il_walk.c) are updated to match.
Tests: regressions/gh-90 (lifetime, including the GCC 9 and Clang 4
modes), regressions/gh-90-old-modes ("A().b" is still a prvalue for GCC
8.3 and Clang 3.9), regressions/gh-90-warn (warnings),
regressions/gh-90-uninit-member ("W().n" and "W().*pn" read an
uninitialized member), cwg/cwg616. Updated
expectations: gnu init/ref19 now passes; clang drs/cwg6xx no longer
rejects the Core issue 616 cases; clang expr.const/p2-0x now diagnoses a
read of a volatile prvalue's member; clang cxx2c-placeholder-vars loses an
"expression has no effect" warning on "S{}._", as in strict mode; a note
caret moves to the member in SemaCXX/constant-expression-cxx2a; gnu
cpp0x/constexpr-delegating3 (delegation to a defaulted constructor, a
separate bug) still fails, but with "access to uninitialized object"
instead of a garbage value.1 parent be1a2e3 commit 78f95ec
67 files changed
Lines changed: 337 additions & 312 deletions
File tree
- src
- pending_changes
- tests
- expectations/edg_x86_64
- tests
- cwg
- .cwg616.rto
- imported
- clang/cpp
- CXX
- drs/.cwg6xx.rto
- expr/expr.const/.p2-0x.rto
- SemaCXX
- .constant-expression-cxx2a.rto
- .cxx2c-placeholder-vars.rto
- gnu/cpp/cpp0x/.constexpr-delegating3.rto
- regressions
- .gh-90-old-modes.rto
- .gh-90-uninit-member.rto
- .gh-90-warn.rto
- .gh-90.rto
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4317 | 4317 | | |
4318 | 4318 | | |
4319 | 4319 | | |
4320 | | - | |
| 4320 | + | |
| 4321 | + | |
| 4322 | + | |
4321 | 4323 | | |
4322 | 4324 | | |
4323 | 4325 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25481 | 25481 | | |
25482 | 25482 | | |
25483 | 25483 | | |
| 25484 | + | |
| 25485 | + | |
| 25486 | + | |
| 25487 | + | |
25484 | 25488 | | |
25485 | 25489 | | |
25486 | 25490 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3267 | 3267 | | |
3268 | 3268 | | |
3269 | 3269 | | |
3270 | | - | |
3271 | | - | |
3272 | | - | |
3273 | | - | |
| 3270 | + | |
| 3271 | + | |
| 3272 | + | |
| 3273 | + | |
3274 | 3274 | | |
3275 | 3275 | | |
3276 | 3276 | | |
| |||
3279 | 3279 | | |
3280 | 3280 | | |
3281 | 3281 | | |
3282 | | - | |
3283 | | - | |
3284 | | - | |
3285 | | - | |
| 3282 | + | |
| 3283 | + | |
| 3284 | + | |
| 3285 | + | |
3286 | 3286 | | |
3287 | 3287 | | |
3288 | 3288 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32261 | 32261 | | |
32262 | 32262 | | |
32263 | 32263 | | |
32264 | | - | |
32265 | | - | |
| 32264 | + | |
| 32265 | + | |
| 32266 | + | |
32266 | 32267 | | |
32267 | 32268 | | |
32268 | 32269 | | |
| |||
32386 | 32387 | | |
32387 | 32388 | | |
32388 | 32389 | | |
32389 | | - | |
32390 | | - | |
| 32390 | + | |
| 32391 | + | |
| 32392 | + | |
32391 | 32393 | | |
32392 | 32394 | | |
32393 | 32395 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7740 | 7740 | | |
7741 | 7741 | | |
7742 | 7742 | | |
7743 | | - | |
7744 | 7743 | | |
7745 | 7744 | | |
7746 | 7745 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
0 commit comments