Opened 8 years ago

Closed 8 years ago

#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 by Even Rouault, 8 years ago

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 by Even Rouault, 8 years ago

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

comment:3 by Even Rouault, 8 years ago

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 by Even Rouault, 8 years ago

Cc: Kurt Schwehr added

comment:5 by Even Rouault, 8 years ago

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

comment:6 by Even Rouault, 8 years ago

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

comment:7 by Even Rouault, 8 years ago

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.