3 ms·
It's even more fun than I remember. This compiles without warnings with "gcc -Wall", and produces an error (declaration of x shadows a parameter) if f4 is uncom
by 112233 2y ago
It's even more fun than I remember. This compiles without warnings with "gcc -Wall", and produces an error (declaration of x shadows a parameter) if f4 is uncommented
struct S {
int x;
int f1() { int x = x; return x; }
int f2(int x) { return [x=x]{return x;}(); }
int f3(int x) { if (int x=x) return x; return x;}
// int f4(int x) { int x=x; return x; }
};
int main(){}
clang warns a bit with -Wall
a.cpp:5:26: warning: variable 'x' is uninitialized when used within its own initialization [-Wuninitialized]
5 | int f3(int x) { if (int x=x) return x; return x;}
| ~ ^