http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56773
Bug #: 56773 Summary: Programs crash if compiled with --coverage, although they run correctly without --coverage Classification: Unclassified Product: gcc Version: 4.7.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: gcov-profile AssignedTo: unassig...@gcc.gnu.org ReportedBy: shavitmichael+...@gmail.com Compiling a C program with the --coverage option causes the program to crash when run if the program has a global variable named "open". Indeed declaring a variable "open" causes an Illegal instruction (core dumped), and initializing it causes a Segmentation fault. Example code: ***** #include <stdio.h> int open = 1; int main(void) { puts(“run”); } ***** Compiling this code with -O0 --coverage, and running the program outputs: run Segmentation fault (core dumped) However, if I remove the --coverage flag, or change the name of the variable "open", the program runs just fine. It looks like the gcov code tries to call a function called open, but ends up calling the variable open. Furthermore this doesn't seem to be an issue in version 4.2, however I haven’t been able to verify for other version between 4.2 and 4.7.2. More specifically, my gcc version is 4.7.2 (Ubuntu/Linaro 4.7.2-2ubuntu1)