public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/37238] New: gcc miscompiles simple memcpy loop
@ 2008-08-25 22:07 felix-gcc at fefe dot de
2008-08-25 22:10 ` [Bug middle-end/37238] " pinskia at gcc dot gnu dot org
2008-08-25 22:11 ` pinskia at gcc dot gnu dot org
0 siblings, 2 replies; 3+ messages in thread
From: felix-gcc at fefe dot de @ 2008-08-25 22:07 UTC (permalink / raw)
To: gcc-bugs
This code:
void byte_copy(void* out, size_t len, const void* in) {
char* s=out;
const char* t=in;
const char* u=t+len;
for (;;) {
if (t==u) break; *s=*t; ++s; ++t;
if (t==u) break; *s=*t; ++s; ++t;
if (t==u) break; *s=*t; ++s; ++t;
if (t==u) break; *s=*t; ++s; ++t;
}
}
gcc produces wrong code with -O1 or higher, but correct code with -O0.
Here is some simple test code:
#include <assert.h>
#include <string.h>
char buf[4096];
char text[128];
int main() {
memset(buf,0,sizeof(buf));
strcpy(text,"this is a test!\n");
byte_copy(buf,16,text);
assert(!memcmp(buf,"this is a test!\n\0",18));
return 0;
}
--
Summary: gcc miscompiles simple memcpy loop
Product: gcc
Version: 4.3.1
Status: UNCONFIRMED
Severity: critical
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: felix-gcc at fefe dot de
GCC build triplet: x86_64-unknown-linux-gnu
GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37238
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug middle-end/37238] gcc miscompiles simple memcpy loop
2008-08-25 22:07 [Bug c/37238] New: gcc miscompiles simple memcpy loop felix-gcc at fefe dot de
@ 2008-08-25 22:10 ` pinskia at gcc dot gnu dot org
2008-08-25 22:11 ` pinskia at gcc dot gnu dot org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-08-25 22:10 UTC (permalink / raw)
To: gcc-bugs
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |pinskia at gcc dot gnu dot
| |org
Severity|critical |normal
Component|c |middle-end
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37238
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug middle-end/37238] gcc miscompiles simple memcpy loop
2008-08-25 22:07 [Bug c/37238] New: gcc miscompiles simple memcpy loop felix-gcc at fefe dot de
2008-08-25 22:10 ` [Bug middle-end/37238] " pinskia at gcc dot gnu dot org
@ 2008-08-25 22:11 ` pinskia at gcc dot gnu dot org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-08-25 22:11 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pinskia at gcc dot gnu dot org 2008-08-25 22:10 -------
*** This bug has been marked as a duplicate of 37090 ***
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |DUPLICATE
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37238
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-08-25 22:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-25 22:07 [Bug c/37238] New: gcc miscompiles simple memcpy loop felix-gcc at fefe dot de
2008-08-25 22:10 ` [Bug middle-end/37238] " pinskia at gcc dot gnu dot org
2008-08-25 22:11 ` pinskia at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).