#6325 closed defect (fixed)

Detect int/bool mismatches

Reported by: Even Rouault Owned by: warmerdam
Priority: normal Milestone:
Component: default Version: unspecified
Severity: normal Keywords:
Cc: Kurt Schwehr

Description

MSVC warns (and errors out in /WX mode) with stuff like "bool b = 1;". This is not easily detectable with compilers available in Linux.

So here's a hack that #define bool MSVCPedanticBool, where MSVCPedanticBool is a C++ class that has a private MSVCPedanticBool(int bIn) constructor. It must be enabled with -DDEBUG_BOOL

Change History (7)

comment:1 Changed 17 months ago by Even Rouault

trunk r33093 "Improve bool'ness (and add explicit static_cast<int>() for printf like operations to be compatible of a bool being a C++ object) (#6325)"

comment:2 Changed 17 months ago by Even Rouault

trunk r33094 "port: other safe bool fixes (#6325)"

comment:3 Changed 17 months ago by Even Rouault

trunk r33095 "Add hack enabled by -DDEBUG_BOOL to detect implicit int->bool conversions that dislike MSVC, and do changes needed to make code compile. Some drivers using C++ headers using bool use -DDO_NOT_USE_DEBUG_BOOL to disable locally DEBUG_BOOL. This mode is only intended to be used at compile time since fragile and known to cause issues in at least the MongoDB driver at runtime (#6325)"

comment:4 Changed 17 months ago by Even Rouault

Cc: Kurt Schwehr added

comment:5 Changed 17 months ago by Even Rouault

trunk r33097 "MongoDB: remove printf trace introduced in previous commit (#6325)"

comment:6 Changed 17 months ago by Even Rouault

trunk r33098 "Add <algorithm> as header to include before installing our #define bool MSVCPedanticBool hack (#6325)"

comment:7 Changed 17 months ago by Even Rouault

Resolution: fixed
Status: newclosed

trunk r33099 "Add explicit int cast for DEBUG_BOOL hack (#6325)"

-DDEBUG_BOOL succesfully enabled in my gdal_coverage/python3 branch

Note: See TracTickets for help on using tickets.