------- Comment #10 from hjl dot tools at gmail dot com  2008-07-23 01:04 
-------
(In reply to comment #9)
> > I said "It comes from an application." It isn't from system header file.
> 
> Yes, and that doesn't answer my question. I asked if the pragma is able to
> suppress a warning triggered by your kind of snippet, IF, when, it appears in
> an header file: I asked about an HYPOTHETICAL situation, not your actual
> situation. Is that more clear?
> 

It doesn't make a difference:

[EMAIL PROTECTED] tmp]$ cat y.h
#pragma GCC system_header
static inline unsigned char *
foo(unsigned char * to, const unsigned char * from, int n)
{
    switch ( n )
    {
    case 3:
      *to = *from;
        break;
    case 5:
        to[4] = from [4];
        break;
    }
    return to;
}
[EMAIL PROTECTED] tmp]$ cat y.c
#include <y.h>

struct {
    int    size_of_select;
    unsigned char pcr_select[4];
} sel;

int main(int argc, char *argv[])
{
    static unsigned char buf[64];

    sel.size_of_select = 3;
    foo(buf, sel.pcr_select, sel.size_of_select);

    return 1;
}
[EMAIL PROTECTED] tmp]$ gcc -Wall -O2 -c y.c -Werror -I.
cc1: warnings being treated as errors
y.c: In function âmainâ:
./y.h:11: error: array subscript is above array bounds
[EMAIL PROTECTED] tmp]$


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36902

Reply via email to