This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/34455] New: Request warning for casts to _Bool
- From: "hpa at zytor dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 13 Dec 2007 19:50:44 -0000
- Subject: [Bug c/34455] New: Request warning for casts to _Bool
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
I recently finished converting a large codebase from using "int" to using
"bool" (i.e. _Bool) for booleans. This is a big win for debuggability.
However, unfortunately the code has to be portable to inferior compilers which
don't have _Bool implemented yet; for those we use:
typedef enum { false, true } bool;
As such, it would be a very nice thing to have an optional warning for any
conversions of non-boolean objects (those not known to contain only 0 or 1) to
_Bool using either an implicit conversion or a cast. The "safe" way to do it
in a backwards-compatible way is using the !! pseudo-operator.
--
Summary: Request warning for casts to _Bool
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: hpa at zytor dot com
GCC build triplet: all
GCC host triplet: all
GCC target triplet: all
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34455