scoping question

Todd todd.freed@gmail.com
Tue Aug 11 16:25:00 GMT 2009


Consider the following code fragment (its kind of long, but makes the 
point well)

int main(int argc, char** argv)
{
  __label__ END;
  int result = 1;

  int inner()
  {
    __label__ END;
    int result = 1;

    result++;
    goto END;

  END:
    printf("inner result: %d\n", result);
    return result;
  };

  inner();
  goto END;

END:
  printf("result: %d\n", result);
  return result;
}

results from running this program:

inner result: 2
result: 1

So when referencing both variables and labels in the inner scope, that 
which is defined in the inner scope is what is used.

My question is, is it possible, from within the inner scope, to refer to 
the variables and labels defined in the outer scope (whose names have 
been overridden)

I am using GCC 4.3.3

Thank you,
Todd



More information about the Gcc-help mailing list