www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/08/24/13:59:07

Message-ID: <35E1A919.45F5@teleline.es>
Date: Mon, 24 Aug 1998 19:55:37 +0200
From: Mariano Alvarez Fernández <malfer AT teleline DOT es>
Reply-To: malfer AT teleline DOT es
Organization: teleline.es
MIME-Version: 1.0
To: djgpp AT delorie DOT com
Subject: Possible bug in GCC

Finally I had catched a strange bug porting a program to DJGPP. It
relies with enum vars. The next example program isolates the problem:

#include <conio.h>
typedef enum { V1, V2, V3 } Tipo;
int main()
{
  Tipo i;
  i = -1;
  if( i < 0 )
    puts( "Negative number" );
  else
    puts( "Positive number" );
}

This program writes with:

DJGPP 2.01 (GCC 2.8.1)        : Positive number.
Debian-Linux 1.3 (GCC 2.7.2.1): Positive number.
BC++ 3.0                      : Negative number.
HP-UX C (10.10)               : Negative number.
HP C/1000 (6.2)               : Negative number.

I think it's a GCC bug because the K&R book (second ed.) say enum types
default to int (not unsigned as DJGPP does). I know I must report that
to the GCC maintainer, but I want to know yours opinions first.

Regards, M.Alvarez

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019