Subject: "comparison is always true" and -fshort-enums
To: None <>
From: Ben Harris <>
List: tech-toolchain
Date: 12/21/2001 13:42:29
NetBSD/arm is likely to convert to setting -fshort-enums as part of its
ELF ABI, so I've been compiling things with that set to see what breaks.
One thing I've found is that the following code (derived from a check in
vfs_subr.c::vfs_vnode_print) always generates a warning:

enum foo { BAR, BAZ };
thing(enum foo arg)

        if (arg < 0)
                return 1;
                return 0;

The warning is:

enum.c:6: warning: comparison is always false due to limited range of data

This warning is correct (the enum is being represented as an unsigned
char), but the test is useful on other architectures, so I'd rather not
remove it.  Casting arg to an int doesn't help, and the only way I've
found to disable the warning is to specify "-w" to gcc, which we obviously
don't want to do globally.

Does anyone have any opinion on what I should do here?

Ben Harris                                                   <>
Portmaster, NetBSD/arm26               <URL:>