🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #49920

2.4.5 vs 2.5.5 and (unsigned) enums

#49920
From: Scott Weitzenkamp
Date: Sat, 04 Dec 1993 05:49
64 lines
4032 bytes
We just upgraded from gcc 2.4.5 to 2.5.5 (on SunOS 4.1.1), and it looks
like enums are now unsigned.  Consider the following program:

% cat enum_unsigned.c

#include <stdio.h>

typedef enum {
  T_SOCKET_CHECK_READ,
  T_SOCKET_CHECK_WRITE
} T_SOCKET_CHECK_MODE;

int main()
{
  T_SOCKET_CHECK_MODE mode = 3;

  if (mode < T_SOCKET_CHECK_READ || mode > T_SOCKET_CHECK_WRITE) {
    printf("bad mode %d\n", mode);
  }
  return 0;
} 

Here's what I get when I compile this program with gcc 2.4.5 and the
(hopefully rather) picky flags we've been using:

% gcc245 -v -c -fpcc-struct-return -ansi -pedantic -Wall -Wshadow -Wid-clash-31 -Wpointer-arith -Wmissing-prototypes -Wnested-externs -g enum_unsigned.c 
Reading specs from /usr/local/lib/gcc-lib/sun4/2.4.5/specs
gcc version 2.4.5
 /usr/local/lib/gcc-lib/sun4/2.4.5/cpp -lang-c -v -undef -D__GNUC__=2 -trigraphs -$ -D__STRICT_ANSI__ -D__sparc__ -D__sun__ -D__unix__ -D__GCC_NEW_VARARGS__ -D__sparc -D__sun -D__unix -D__GCC_NEW_VARARGS__ -g -Wall -Wshadow -Wid-clash-31 -Wpointer-arith -Wmissing-prototypes -Wnested-externs -pedantic enum_unsigned.c /usr/tmp/cca18641.i
GNU CPP version 2.4.5 (sparc)
 /usr/local/lib/gcc-lib/sun4/2.4.5/cc1 /usr/tmp/cca18641.i -quiet -dumpbase enum_unsigned.c -g -Wall -Wshadow -Wid-clash-31 -Wpointer-arith -Wmissing-prototypes -Wnested-externs -pedantic -ansi -version -fpcc-struct-return -o /usr/tmp/cca18641.s
GNU C version 2.4.5 (sparc) compiled by GNU C version 2.4.5.
 as -o enum_unsigned.o /usr/tmp/cca18641.s

  No problem.  Now here's the same program, but compiled with gcc
2.5.5 instead of 2.4.5.

% gcc -v -c -fpcc-struct-return -ansi -pedantic -Wall -Wshadow -Wid-clash-31 -Wpointer-arith -Wmissing-prototypes -Wnested-externs -g enum_unsigned.c 
Reading specs from /usr/local/gnu/sun4_sunos_4_1_1/lib/gcc-lib/sparc-sun-sunos4.1.1/2.5.5/specs
gcc version 2.5.5
 /usr/local/gnu/sun4_sunos_4_1_1/lib/gcc-lib/sparc-sun-sunos4.1.1/2.5.5/cpp -lang-c -v -undef -D__GNUC__=2 -D__GNUC_MINOR__=5 -trigraphs -$ -D__STRICT_ANSI__ -D__sparc__ -D__sun__ -D__unix__ -D__GCC_NEW_VARARGS__ -D__sparc -D__sun -D__unix -D__GCC_NEW_VARARGS__ -Asystem(unix) -Asystem(bsd) -Acpu(sparc) -Amachine(sparc) -g -Wall -Wshadow -Wid-clash-31 -Wpointer-arith -Wmissing-prototypes -Wnested-externs -pedantic enum_unsigned.c /usr/tmp/cca18581.i
GNU CPP version 2.5.5 (sparc)
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/local/gnu/sun4_sunos_4_1_1/sparc-sun-sunos4.1.1/include
 /usr/local/gnu/sun4_sunos_4_1_1/lib/gcc-lib/sparc-sun-sunos4.1.1/2.5.5/include
 /usr/include
End of search list.
 /usr/local/gnu/sun4_sunos_4_1_1/lib/gcc-lib/sparc-sun-sunos4.1.1/2.5.5/cc1 /usr/tmp/cca18581.i -quiet -dumpbase enum_unsigned.c -g -Wall -Wshadow -Wid-clash-31 -Wpointer-arith -Wmissing-prototypes -Wnested-externs -pedantic -ansi -version -fpcc-struct-return -o /usr/tmp/cca18581.s
GNU C version 2.5.5 (sparc) compiled by GNU C version 2.5.5.
enum_unsigned.c: In function `main':
enum_unsigned.c:12: warning: unsigned value < 0 is always 0
 as -o enum_unsigned.o /usr/tmp/cca18581.s

Notice how it complains about an "unsigned value".

If anyone can shed some light on this problem, I'd sure appreicate it.
-- 
Thanks in advance...
Scott Weitzenkamp, Talarian Corporation, Mountain View, CA
scott@talarian.com OR uunet!talarian!scott     	(415) 965-8050
"Welcome to the late show, starring NULL and void" -- Men At Work
Technical Details
Message-ID: <CHHxIC.3GI@talarian.com>
Path: arc1-ca.pugleaf.net!gmd.de!xlink.net!howland.reston.ans.net!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!decwrl!netcomsv!netcomsv!conan!scott

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,ff3bafe84fab3f11,start
X-Google-Attributes: gid11318c,public
X-Google-ArrivalTime: 1993-12-07 01:26:37 PST
Newsgroups: gnu.gcc.help
Path: arc1-ca.pugleaf.net!gmd.de!xlink.net!howland.reston.ans.net!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!decwrl!netcomsv!netcomsv!conan!scott
From: scott@talarian.com (Scott Weitzenkamp)
Subject: 2.4.5 vs 2.5.5 and (unsigned) enums
Message-ID: <CHHxIC.3GI@talarian.com>
Organization: Talarian Corporation
Date: Sat, 4 Dec 1993 05:49:04 GMT
Lines: 64