https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106080
--- Comment #10 from Marek Polacek <mpolacek at gcc dot gnu.org> --- (In reply to Andrew Pinski from comment #8) > (In reply to Marek Polacek from comment #7) > > I know you can't jump into a statement expression but that's not what's > > happening here. The kernel uses this trick to get the current address for > > error messages: > > > > #define __this_address ({ __label__ __here; __here: barrier(); &&__here; }) > > > > and they will have to disable the warning completely because of it. The > > manual for -Wdangling-pointer also talks about pointers to *objects* and > > labels aren't objects. > > But that is undefined at what label or even where label would be located; it > could be located anywhere. The kernel use of this extension should be > removed as it is not using it to get an useful value at all. Maybe we should > add another builtin to get the current PC. Apparently it's worked for them. XFS uses __this_address as defined above, the rest of the kernel uses #define _RET_IP_ (unsigned long)__builtin_return_address(0) #define _THIS_IP_ ({ __label__ __here; __here: (unsigned long)&&__here; }) Maybe we should have __builtin_current_pc but we don't. > Also can't they turn off the warning inside the statement expression/around > the macro? That's a question for them. I continue to think that warning about non-objects is a flaw and not useful.