Summary: | [4.0/4.1 Regression] member function pointers | ||
---|---|---|---|
Product: | gcc | Reporter: | Yu Yang <gnu04> |
Component: | middle-end | Assignee: | Not yet assigned to anyone <unassigned> |
Status: | RESOLVED INVALID | ||
Severity: | critical | CC: | gcc-bugs |
Priority: | P1 | Keywords: | wrong-code |
Version: | 4.0.0 | ||
Target Milestone: | 4.0.1 | ||
Host: | Target: | i686-pc-linux-gnu | |
Build: | Known to work: | ||
Known to fail: | Last reconfirmed: | ||
Attachments: | This is the source file. |
Description
Yu Yang
2005-04-28 19:07:32 UTC
Created attachment 8759 [details]
This is the source file.
This works at -O0. But at -O1 or above. Hmm, this also works just fine on ppc-darwin too. Actually this is invalid, you are going passed the bounds of buf. %.2x does not do what you want it to do. You want to do the following instead: void conv_ptr(void * ptr, char* buf) { unsigned char * str = (unsigned char*)ptr; int i; for(i = 0; i < 3 ; i++) sprintf(buf+i*2, "%.2x", str[i]); buf[8] = 0; } If you turned on mudflap you would find that we have a violation: ******* mudflap violation 1 (check/write): time=1114716962.109669 ptr=0xbfe79f35 size=9 pc=0xd40568 location=`(sprintf str)' /home/peshtigo/pinskia/linux/lib/libmudflap.so.0(__mf_check+0x48) [0xd40568] /home/peshtigo/pinskia/linux/lib/libmudflap.so.0(__mfwrap_sprintf+0x16c) [0xd4957c] ./a.out(_Z8conv_ptrPvPc+0xcc) [0x8048950] Nearby object 1: checked region begins 2B into and ends 2B after mudflap object 0x9a2f7d0: name=`t.cc:30 (main) char buf [9]' bounds=[0xbfe79f33,0xbfe79f3b] size=9 area=stack check=0r/5w liveness=5 alloc time=1114716962.109589 pc=0xd410a8 number of nearby objects: 1 |