================
@@ -849,13 +849,11 @@ namespace CompoundLiterals {
}
static_assert(get5() == 5, "");
- constexpr int get6(int f = (int[]){1,2,6}[2]) { // ref-note {{subexpression
not valid in a constant expression}} \
- // ref-note {{declared here}}
+ constexpr int get6(int f = (int[]){1,2,6}[2]) {
----------------
AaronBallman wrote:
> With the VLA example, there are a few different weird interactions here...
> but the primary silly thing I'm doing is abusing VLAs to modify argument
> values.
Yeah, which we already seem to get wrong: https://godbolt.org/z/Y4xEGWhM3
> On top of that, we have to consider the question of the lifetime of compound
> literals defined inside the array bound.
I think that's what `object backing the pointer x will be destroyed at the end
of the full-expression` is about in your previous VLA example. There is an
`ExprWithCleanups` node for the assignment operator and that is a `FullExpr`.
So I think we do get that correct -- I'll add it as a test case with comments
explaining why it's rejected.
> But maybe we should just reject this sort of thing in C++ more aggressively,
> like gcc does, so we don't have to figure out all these weird cases.
I tend to agree we should be far more restrictive with VLAs in C++ than we are
today. But I also think that's a different PR than this one. WDYT?
https://github.com/llvm/llvm-project/pull/132097
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits