https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121677
Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution|--- |INVALID --- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to Csaba Ráduly from comment #0) > int i = 42; > auto f = [&i] () { return i * 2; }; // not called > f.__i = 13; Your code has undefined behaviour because you're using a reserved identifier. The point of reserving names like __i for the implementation is to allow them to be used by the implementation *for any purpose*, including as members of unspecified types like lambda closures. > This should not happen. __i is not defined anywhere (clang and msvc reject > the code because of this). User code should not have access to the internal > implementation of lambdas. There's no way to access it without undefined behaviour, so a valid program cannot access it.