[Bug c/110453] New: gcc accepts redefinition of global variable without initializer
laneast at laneast dot com
gcc-bugzilla@gcc.gnu.org
Wed Jun 28 11:13:29 GMT 2023
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110453
Bug ID: 110453
Summary: gcc accepts redefinition of global variable without
initializer
Product: gcc
Version: 13.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: laneast at laneast dot com
Target Milestone: ---
gcc accepts following program:
#include <stdio.h>
int x;
int x = 10;
int main() {
printf("%d\n", x);
return 0;
}
--------
Tested gcc version:
* gcc.exe (Rev7, Built by MSYS2 project) 13.1.0
* gcc (Debian 12.2.0-14) 12.2.0
BTW, g++ works fine:
main.c:4:5: error: redefinition of 'int x'
4 | int x = 10;
| ^
main.c:3:5: note: 'int x' previously declared here
3 | int x;
| ^
More information about the Gcc-bugs
mailing list