c/2707: gcc does not warn on truncate

jhabermann@tricord.com jhabermann@tricord.com
Tue May 1 11:06:00 GMT 2001


>Number:         2707
>Category:       c
>Synopsis:       gcc does not warn on truncate
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue May 01 11:06:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     jhabermann@tricord.com
>Release:        unknown-1.0
>Organization:
>Environment:

>Description:
gcc does not warn when assigning a "larger" variable
to a smaller one.  Example:

#include <stdio.h>
int
main(int argc, char **argv)
{
    unsigned long i32;
    unsigned short i16;
    i32 = 0xffffffff;
    i16 = i32; /* should warn here, I think */
    printf("i32 = 0x%lx, i16 = 0x%x\n", i32, (unsigned int)i16);
    printf("sizeof(i32) = %d, sizeof(i16) = %d\n", sizeof(i32),
	sizeof(i16));
    return(0);
}

>How-To-Repeat:

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gcc-prs mailing list