http://llvm.org/bugs/show_bug.cgi?id=13547
Bug #: 13547
Summary: clang optimizes away null terminator
Product: clang
Version: trunk
Platform: PC
OS/Version: other
Status: NEW
Severity: normal
Priority: P
Component: Driver
AssignedTo: [email protected]
ReportedBy: [email protected]
CC: [email protected]
Classification: Unclassified
#include <stdio.h>
#include <string.h>
int
main(void)
{
char buf[1024], *c;
int i;
for (i = 0; i < 100; i++)
buf[i] = '/';
buf[i] = '\0';
c = strdup(buf);
printf("%s\n", c);
return (0);
}
when compiled with -O0, the above code works normally. With any optimization
enabled, the "buf[i] = '\0'" is discarded.
(dhill@olive ~/code)$ clang -O0 -o test test.c
(dhill@olive ~/code)$ ./test
////////////////////////////////////////////////////////////////////////////////////////////////////
(dhill@olive ~/code)$ clang -O1 -o test test.c
(dhill@olive ~/code)$ ./test
ÐÒèÿÿÿÿÀ$
Can anyone reproduce this with the current trunk?
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs