3 ms·
> whatever is going on with $__anon The "lambda$__anon$" identifer is just the name of the local function, it could just as well have been "elephant" or anythi
by quietbritishjim 7y ago
> whatever is going on with $__anon
The "lambda$__anon$" identifer is just the name of the local function, it could just as well have been "elephant" or anything else. The first line defines the nested function:
{
double elephant (double x){ return x/3; }
And the second line references that same identifer:
&elephant;
}
Normally an expression that didn't include an assignment call or a function call is legal but doesn't do anything. But as the article mentions, GCC uses it as the return value of the block.
The commenters seem to have identified the undefined behaviour here: the resulting value is a pointer to a function that's only valid within the block but is being used outside it.
- ramshorns 7y agoWhat do the dollar signs do? If they're really just part of the identifier it doesn't seem necessary to make sure the compiler supports it, rather than just use a more normal name like elephant.
- gpderetta 7y agoIt is just a way to uglify symbols to make collisions with surrounding code less likely. C macros are not hygienic.