[PATCH] D124351: [Clang] Implement Change scope of lambda trailing-return-type
    Jordan Rupprecht via Phabricator via cfe-commits 
    cfe-commits at lists.llvm.org
       
    Thu Feb  2 20:38:30 PST 2023
    
    
  
rupprecht added a comment.
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?
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