[PATCH] D124351: [Clang] Implement Change scope of lambda trailing-return-type
Corentin Jabot via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 2 23:32:17 PST 2023
cor3ntin added a comment.
In D124351#4101611 <https://reviews.llvm.org/D124351#4101611>, @rupprecht wrote:
> Hi, me again :)
>
> I ran into an interesting build breakage from this, I can't tell if it's a legitimate breakage based on reading P2036R3 and P2579R0 (mostly I'm not a language lawyer).
>
> struct StringLiteral {
> template <int N>
> StringLiteral(const char (&array)[N])
> __attribute__((enable_if(N > 0 && N == __builtin_strlen(array) + 1,
> "invalid string literal")));
> };
>
> struct Message {
> Message(StringLiteral);
> };
>
> void Func1() {
> auto x = Message("x"); // Note: this is fine
>
> // Note: "xx\0" to force a different type, StringLiteral<3>, otherwise this
> // successfully builds.
> auto y = [&](decltype(Message("xx"))) {};
>
> // ^ fails with: repro.cc:18:13: error: reference to local variable 'array'
> // declared in enclosing function 'StringLiteral::StringLiteral<3>'
>
> (void)x;
> (void)y;
> }
>
> https://godbolt.org/z/M4E6jKxxn
>
> Does this look like an intended breakage from this patch?
Looks like we fail to enter the appropriate context when evaluating the lambda, definitely
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D124351/new/
https://reviews.llvm.org/D124351
More information about the cfe-commits
mailing list