[geos-devel] [GEOS] #638: Recommend a static_cast around assert strings

GEOS geos-trac at osgeo.org
Tue Jan 31 13:51:46 PST 2017


#638: Recommend a static_cast around assert strings
------------------------+---------------------------
 Reporter:  goatbar     |       Owner:  geos-devel@…
     Type:  defect      |      Status:  new
 Priority:  major       |   Milestone:  3.7.0
Component:  Default     |     Version:  3.3.8
 Severity:  Unassigned  |  Resolution:
 Keywords:              |
------------------------+---------------------------

Comment (by goatbar):

 mloskot: Can you please explain and give a reference why `!!!""` is
 equivalent to `!static_cast<bool>("")`?  I've never seen that in C++ for C
 strings.

 If I try `!!!` in C++11/14, I get the same type of error:

 {{{
 src/operation/union/CascadedUnion.cpp:119:23: error: implicit conversion
 turns string literal into bool: 'const char [24]' to 'bool' [-Werror
 ,-Wstring-conversion]
             assert(!!!"should never be reached");
 }}}

 I found this for *javascript* http://stackoverflow.com/questions/21154510
 /the-use-of-the-triple-exclamation-mark

 https://cboard.cprogramming.com/c-programming/133581-what-double-
 exclamation-mark-c-language.html#post994202

--
Ticket URL: <https://trac.osgeo.org/geos/ticket/638#comment:12>
GEOS <http://trac.osgeo.org/geos>
GEOS (Geometry Engine - Open Source) is a C++ port of the Java Topology Suite (JTS).


More information about the geos-devel mailing list