Last active
January 14, 2023 03:20
-
-
Save yyasuda/bb6c0ad6ffcbf6a526d775c360398a98 to your computer and use it in GitHub Desktop.
The initializer of a structure variable can include a reference to itself
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
LLVM reports a warning as follows; | |
"variable 's' is uninitialized when used within its own initialization [-Wuninitialized]" | |
But it shows the answer "3" correctly. | |
*/ | |
#include <stdio.h> | |
typedef struct { | |
int a, b, c; | |
} S; | |
int sum(S s) { | |
return s.a + s.b; | |
} | |
int main() { | |
S s = {1, 2, sum(s)}; | |
printf("%d %d %d\n", s.a, s.b, s.c); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Assembled code is here;
https://gist.github.com/yyasuda/c5633cea0e9c9de303f15a3af4c5d324