This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/29429] New: Incorrect code with -O
- From: "alireza dot salimi at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 11 Oct 2006 09:47:42 -0000
- Subject: [Bug c/29429] New: Incorrect code with -O
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The code below works correctly when no Optimization flag is given to gcc and
process exits as soon as a SIGHUP is sent to it.
But if it is compiled with any one of -O flags, sending SIGHUP does not
terminate the process.
sig_atomic_t hup_rcvd = 0;
void hup_handler(int signo)
{
hup_rcvd = 1;
}
int main()
{
if (signal(SIGHUP, hup_handler) == SIG_ERR) {
fprintf(stderr, "signal failed\n");
return -1;
}
for (hup_rcvd = 0; !hup_rcvd; ) {
;
}
return 0;
}
--
Summary: Incorrect code with -O
Product: gcc
Version: 3.4.4
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: alireza dot salimi at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29429