From MAILER-DAEMON Sat Dec 21 17:27:40 2019
Received: from list by lists.gnu.org with archive (Exim 4.90_1)
	id 1iinDo-0004qJ-Nq
	for mharc-bug-commoncpp@gnu.org; Sat, 21 Dec 2019 17:27:40 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:45539)
 by lists.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <fbriere@fbriere.net>) id 1iimrg-0007Rs-43
 for bug-commoncpp@gnu.org; Sat, 21 Dec 2019 17:04:48 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <fbriere@fbriere.net>) id 1iimre-0004IG-HF
 for bug-commoncpp@gnu.org; Sat, 21 Dec 2019 17:04:47 -0500
Received: from smtp-out-4.mxes.net ([198.205.123.69]:46368)
 by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <fbriere@fbriere.net>) id 1iimre-0003zY-1o
 for bug-commoncpp@gnu.org; Sat, 21 Dec 2019 17:04:46 -0500
Received: from Customer-MUA (mua.mxes.net [10.0.0.1])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits))
 (No client certificate requested)
 by smtp.mxes.net (Postfix) with ESMTPSA id 52A94273A7
 for <bug-commoncpp@gnu.org>; Sat, 21 Dec 2019 17:04:36 -0500 (EST)
Received: by fabul.fbriere.net (Postfix, from userid 1000)
 id 42B7FE09E6; Sat, 21 Dec 2019 17:04:35 -0500 (EST)
Date: Sat, 21 Dec 2019 17:04:35 -0500
From: =?utf-8?B?RnLDqWTDqXJpYyBCcmnDqHJl?= <fbriere@fbriere.net>
To: bug-commoncpp@gnu.org
Subject: #include <ucommon/ucommon.h> unexpectedly defines NDEBUG
Message-ID: <20191221220434.GA26264@fabul.fbriere.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
User-Agent: Mutt/1.10.1 (2018-07-13)
X-Sent-To: <YnVnLWNvbW1vbmNwcEBnbnUub3Jn>
X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x [fuzzy]
X-Received-From: 198.205.123.69
X-Mailman-Approved-At: Sat, 21 Dec 2019 17:27:39 -0500
X-BeenThere: bug-commoncpp@gnu.org
X-Mailman-Version: 2.1.23
Precedence: list
List-Id: Bug reports for Common C++ <bug-commoncpp.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/bug-commoncpp>,
 <mailto:bug-commoncpp-request@gnu.org?subject=unsubscribe>
List-Archive: <https://lists.gnu.org/archive/html/bug-commoncpp>
List-Post: <mailto:bug-commoncpp@gnu.org>
List-Help: <mailto:bug-commoncpp-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/bug-commoncpp>,
 <mailto:bug-commoncpp-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sat, 21 Dec 2019 22:04:49 -0000

When included, ucommon/ucommon.h (via platform.h) unexpectedly defines
NDEBUG without any warning, unless DEBUG has already been defined.

That led to a lot of head-scratching, trying to figure out why assert()
was sometimes, but not always, not doing its job while working on a
project that uses uCommon in some places.

(For the record, this was encountered in version 7.0.0, but seems to
have been present forever.)


 $ cat ucommon-ndebug.cpp
     #ifdef NDEBUG
     #warning "NDEBUG was already defined before including <ucommon/ucommon.h>"
     #endif
     
     #include <ucommon/ucommon.h>
     
     #ifdef NDEBUG
     #error "NDEBUG is defined after including <ucommon/ucommon.h>"
     #endif

 $ g++ -E ucommon-ndebug.cpp >/dev/null && echo OK
 ucommon-ndebug.cpp:8:2: error: #error "NDEBUG is defined after including <ucommon/ucommon.h>"
  #error "NDEBUG is defined after including <ucommon/ucommon.h>"
   ^~~~~

 $ g++ -E -DDEBUG ucommon-ndebug.cpp >/dev/null && echo OK
 OK



