http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56105
Bug #: 56105 Summary: Simple ANSI C 89 code -> Mudflap false violation Classification: Unclassified Product: gcc Version: 4.7.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libmudflap AssignedTo: unassig...@gcc.gnu.org ReportedBy: m.labanow...@gmail.com $ gcc --version gcc (Ubuntu/Linaro 4.7.2-11precise2) 4.7.2 $ gawk '{printf("%02u: %s\n", NR, $0);}' bar.c 01: long bar_fun(unsigned idx) { 02: long bar_cfg [][2] = { 03: {9, 0}, {8, 1}, {7, 2}, {6, 3}, 04: {5, 4}, {4, 5}, {3, 6}, {2, 7}, 05: {0, 9} 06: }; 07: return (idx < (unsigned)(sizeof(bar_cfg) / sizeof(*bar_cfg))) 08: ? bar_cfg[idx][1] : -1; 09: } $ gawk '{printf("%02u: %s\n", NR, $0);}' main.c 01: #include <stdio.h> /* printf */ 02: #include <stdlib.h> /* EXIT_SUCCESS */ 03: long bar_fun(unsigned idx); 04: static long foo_fun(unsigned idx) { 05: long const TOSTEP [][2] = { 06: {0, 9}, {1, 8}, {2, 7}, {3, 6}, 07: {4, 5}, {5, 4}, {6, 3}, {7, 2}, 08: {8, 1}, {9, 0} 09: }; 10: return (idx < (unsigned)(sizeof(TOSTEP) / sizeof(*TOSTEP))) 11: ? (int)(TOSTEP[idx][1]) : -1; 12: } 13: int main(void) { 14: printf("foo_fun = %ld\r\n", foo_fun(4)); 15: printf("bar_fun = %ld\r\n", bar_fun(4)); 16: return EXIT_SUCCESS; 17: } $ gcc -ansi -pedantic -Wall -W -Werror -fmudflap bar.c main.c -lmudflap -o a.out $ echo ":${MUDFLAP_OPTIONS}:" :: $ ./a.out ******* mudflap violation 1 (register): time=1359114674.510460 ptr=0xbfd664d0 size=80 pc=0xb76c3b4e /usr/lib/i386-linux-gnu/libmudflap.so.0(__mf_register+0x3e) [0xb76c3b4e] ./a.out() [0x8048ab9] ./a.out(__libc_csu_init+0x52) [0x8048b62] Nearby object 1: checked region begins 8B before and ends 71B into mudflap object 0x89081e8: name=`constant' bounds=[0xbfd664d8,0xbfd6651f] size=72 area=static check=0r/0w liveness=0 alloc time=1359114674.510456 pc=0xb76c3b4e number of nearby objects: 1 foo_fun = 5 bar_fun = 4 -----[END]-------