Last active
July 5, 2022 10:27
-
-
Save yohhoy/45743ae6572855e3bb30aa39879c53e9 to your computer and use it in GitHub Desktop.
Fibonacci with VLA on C99
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
#include <stdio.h> | |
size_t f(size_t, char [][*]); | |
size_t f(size_t n, char r[][2 < n ? f(n-2, 0) + f(n-1, 0) : 1]) | |
{ | |
return sizeof(*r); | |
} | |
int main() | |
{ | |
printf("%zu\n", f(10, 0)); // 55 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is UB. See https://stackoverflow.com/questions/32985424/is-the-operand-of-sizeof-evaluated-with-a-vla/