On Tue, Apr 14, 2020 at 05:59:18PM -0700, Linus Torvalds wrote: > On Tue, Apr 14, 2020 at 4:09 PM Luc Van Oostenryck > <luc.vanoostenryck@xxxxxxxxx> wrote: > > > > + if (s->scope != s->declared_scope) { > > > > This comparison can never succeed for labels declared with __label__ > > because s->scope is a block scope and s->declared_scope a label one. > > Hold on.. I'm sure I tested it. > > Oh. > > What I tested wasn't what I sent you, and I'd fixed things due to the > testing but not updated the patch file. > > Oops. > > The test is supposed to be > > if (s->declared_scope != label_scope) { > > which is the whole point of that 'declared_scope'. > > So the concept of the patch is that the 'declared_scope' (and > 'label_scope') are the same kind of scope (and comparable): it is the > applicability of the label itself (either the whole function or some > sub-expression statement). > > And the the visibility of the -symbol- ends up being different, and is > the s->scope thing. > > But while my testing wasn't quite as limited as my wrong-version patch > implied, it _was_ limited. So it might miss some other case. Sorry for the late reply. Yes, it's working OK wth this change but there are several issues that make me think that this approach is not ideal: 1) these 2 functions would give very different error message: void foo(void) { goto l; ({ l: 0; }); } void bar(void) { ({ l: 0; }); goto l; } The first one gives the 'warning: jumping inside statement expression' while the second one can only give 'warning: goto with undeclared label' because indeed the 'l' label inside the statement isn't visible anymore. This second warning is of coure less informative than the first one but what I really find abnormal is that the warning would be different depending on the fact that the goto comes before or after the label definition. This seems incorrect to me, confusing and is different from GCC (clang doesn't seems to mind). 2) in the following case, no warning can be given: void foo(void) { l: ({ l: goto l; 0; }); goto l; } In this case both label definition are in a different scope and each goto sees its own label. This is different than GCC which would complain about 'l' being redeclared. There was also another issue related to the fact that GCC put all labels in a single namespace bit I forgot the details. These two problems are linked to the fact of using the local namespace for labels while GCC use a single one for all of them. But well, then again I can't say I'm fully happy with my solution using the label scope not for the labels but for their definition and uses (gotos & label expressions) and then comparing these with the helper is_in_scope(). I dunno. I've fixed a number of details, I'll repost everything soon. -- Luc