Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 3 Jan 2014 01:41:51 GMT
From:      Stephen Hurd <shurd@sasktel.net>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   bin/185431: gcc bug with short int promotion
Message-ID:  <201401030141.s031fp59044345@oldred.freebsd.org>
Resent-Message-ID: <201401030150.s031o0XH044048@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>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@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:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201401030141.s031fp59044345>