cppfront
cppfront copied to clipboard
[BUG] Global variable treated as local variable by initialization safety guarantee rule
The initialization safety guarantee informs that the global variable is a local variable and that it needs to be initialized before the local variable in the function.
i : int;
main: () -> int = {
j : int;
j = 42;
i = 12;
}
Compile it with cppfront and we get an error:
cppfront % build/external/cppfront external/tests/global_variable.cpp2
external/tests/global_variable.cpp2...
global_variable.cpp2(5,5): error: local variable i must be initialized before j (local variables must be initialized in the order they are declared)
==> program violates initialization safety guarantee - see previous errors
Expected behavior: i
is a global variable and (according to the error message) should not be considered in checking the order of initialization of the local variables.