Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 14 Jun 1996 14:59:09 -0700 (PDT)
From:      Julian Elischer <julian>
To:        hackers
Subject:   unexpected gcc behaviour in freebsd?
Message-ID:  <199606142159.OAA22588@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
 The following program doesn't do what I expected..

is this right?
I spent an hour chasing a problem in a driver because of this...

> cat x.c
#include <stdio.h>
unsigned short a,b;
main()
{
        unsigned short a,b;

        a = 0;
        b = ~a;
        if ( b == ~a) {
                printf("expected result\n");
        } else {
                printf("unexpected result\n");
        }
        exit(0);
}


> cc x.c
> ./a.out
unexpected result
> 
 the operation ~a seems to promote to LONG which causes odd behaviour..

certainly seems broken to me..

anyone have 2.7.2 to check this on..
gcc on freefall seems to do the unexpected thing..

julian

 .



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