bin/185431: gcc bug with short int promotion

Stephen Hurd shurd at sasktel.net
Fri Jan 3 01:50:00 UTC 2014


>Number:         185431
>Category:       bin
>Synopsis:       gcc bug with short int promotion
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jan 03 01:50:00 UTC 2014
>Closed-Date:
>Last-Modified:
>Originator:     Stephen Hurd
>Release:        9.1-RELEASE-p6
>Organization:
>Environment:
FreeBSD cracked.hurd.local 9.1-RELEASE-p6 FreeBSD 9.1-RELEASE-p6 #0: Wed Aug 21 20:30:17 UTC 2013     root at amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC  i386

>Description:
Integer promotion of a short int and an unsigned short in the same expression seems broken in the system compiler.
>How-To-Repeat:
#include <stdio.h>

int main(int argc, char **argv)
{
        short k = 251;
        unsigned short l = 65535;

        printf("%hd > %hu = %d\n", k, l, (k > l));
        return 0;
}

> gcc test.c
> ./a.out
251 > 65535 = 1
>Fix:
Use a different compiler.

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


More information about the freebsd-bugs mailing list