Yes, it does cause overflow. Luckily your program is short enough that you didn’t notice the damage.
Your code writes 8 bytes into a 4 byte variable. This will scribble on whatever follows a
in memory. In your case there are no declarations after a
, so it probably wrote over free space, but that’s not guaranteed. Whatever, it appears that nothing critical depended on that memory for successful completion of your program.
Some compilers may be able to detect this, but some will not. In the general case, where a
is declared in a different source file, this is undetectable. This is why it is good practice to put extern
declarations in a header file, and then include that header in the source file that declares the real variable, as well as the source files that use it; that way the compiler gets a chance to check the declarations match.
solved extern type declaration conflict in C