[llvm-bugs] [Bug 27604] New: Wrong optimization when goto jumps backwards over declaration
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon May 2 09:22:03 PDT 2016
https://llvm.org/bugs/show_bug.cgi?id=27604
Bug ID: 27604
Summary: Wrong optimization when goto jumps backwards over
declaration
Product: clang
Version: unspecified
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: -New Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: cherepan at mccme.ru
CC: llvm-bugs at lists.llvm.org
Classification: Unclassified
The program:
#include <stdio.h>
int main()
{
int *p = 0;
start:
if (p) {
printf("%d\n", *p);
return 0;
}
int x;
x = 1;
p = &x;
goto start;
}
should print "1" but prints "0" when compiled with clang -O1.
Tested on clang version 3.9.0 (trunk 268228).
Tests with https://gcc.godbolt.org/ show that it started between 3.6 and 3.7.
The reason probably is insertion of llvm.lifetime.start where a declaration
occurs instead of where the corresponding block starts.
The relevant part of C11 is 6.2.4p5-6: "An object whose identifier is declared
with no linkage and without the storage-class specifier static has automatic
storage duration, as do some compound literals. [...] For such an object that
does not have a variable length array type, its lifetime extends from entry
into the block with which it is associated until execution of that block ends
in any way."
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160502/34baf401/attachment-0001.html>
More information about the llvm-bugs
mailing list