https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98109

James Legg <jlegg at feralinteractive dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jlegg at feralinteractive dot 
com

--- Comment #2 from James Legg <jlegg at feralinteractive dot com> ---
The false positives can often be seen when converting a lambda to a function
pointer at lower optimisation levels too. For example, in g++ 11.1.1,
compiling:
int main()
{
        return static_cast<int (*)(int)>([](int x){ return x; })(0);
}

with -Og -Wall -fsanitize=undefined results in:
/tmp/a.cc: In static member function ‘static constexpr int
main()::<lambda(int)>::_FUN(int)’:
/tmp/a.cc:3:63: warning: ‘this’ pointer is null [-Wnonnull]
    3 |         return static_cast<int (*)(int)>([](int x){ return x; })(0);
      |                                                               ^
/tmp/a.cc:3:42: note: in a call to non-static member function
‘main()::<lambda(int)>’
    3 |         return static_cast<int (*)(int)>([](int x){ return x; })(0);
      |                                          ^
  • [Bug middle-end/98109] Seem... jlegg at feralinteractive dot com via Gcc-bugs

Reply via email to