From nobody@FreeBSD.org  Tue Dec 18 20:31:40 2012
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id 2833EE81
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 18 Dec 2012 20:31:40 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 0D35B8FC18
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 18 Dec 2012 20:31:40 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.5/8.14.5) with ESMTP id qBIKVdqC020573
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 18 Dec 2012 20:31:39 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.5/8.14.5/Submit) id qBIKVdMr020571;
	Tue, 18 Dec 2012 20:31:39 GMT
	(envelope-from nobody)
Message-Id: <201212182031.qBIKVdMr020571@red.freebsd.org>
Date: Tue, 18 Dec 2012 20:31:39 GMT
From: Robin Carey <robin.carey1@googlemail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: UINT64_MAX missing in C++ Program
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         174549
>Category:       misc
>Synopsis:       UINT64_MAX missing in C++ Program
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Dec 18 20:40:00 UTC 2012
>Closed-Date:    Sun Dec 30 03:30:34 UTC 2012
>Last-Modified:  Sun Dec 30 03:30:34 UTC 2012
>Originator:     Robin Carey
>Release:        9.1-R/i386 and 9.0-R/i386
>Organization:
None
>Environment:
Abbreviated:

FreeBSD 9.1-RELEASE #0 r243826 GENERIC i386

Bug also present on:

FreeBSD 9.0-RELEASE GENERIC i386
>Description:
The bug seems to be C++ related (I doubt it is also present in the C
programming language environment).


The bug can be reproduced by downloading the following C++ software:

http://www.leopard.uk.com/CP

[ The file cp1.tgz is available at the above URL; tar archive; gzipped ]


If you then examine/edit the file: Counter128.h, you will be able to comment/uncomment the following cpp directive:

// Work-around a bug in FreeBSD-9.0/i386 where the UINT*_MAX parameters
// are not defined by the <stdint.h> inclusion:
//
# ifndef  UINT64_MAX
# define  UINT64_MAX 0xffffffffffffffffULL
# endif

If the above cpp directive is commented out, the program will fail to compile with the error:

Counter128.h: 104: error: `UINT64_MAX' was not declared in this scope


Note: I assumed this bug would have been fixed in 9.1-R (after encountering it in 9.0-R.
>How-To-Repeat:
The bug can be reproduced by downloading the following C++ software:

http://www.leopard.uk.com/CP

[ The file cp1.tgz is available at the above URL; tar archive; gzipped ]


If you then examine/edit the file: Counter128.h, you will be able to comment/uncomment the following cpp directive:

// Work-around a bug in FreeBSD-9.0/i386 where the UINT*_MAX parameters
// are not defined by the <stdint.h> inclusion:
//
# ifndef  UINT64_MAX
# define  UINT64_MAX 0xffffffffffffffffULL
# endif

If the above cpp directive is commented out, the program will fail to compile with the error:

Counter128.h: 104: error: `UINT64_MAX' was not declared in this scope

>Fix:
[ not known ]

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-i386->freebsd-bugs 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Mon Dec 24 08:56:48 UTC 2012 
Responsible-Changed-Why:  
not i386-specific. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=174549 

From: "b.f." <bf1783@googlemail.com>
To: bug-followup@FreeBSD.org, Robin Carey <robin.carey1@googlemail.com>
Cc:  
Subject: Re: misc/174549: UINT64_MAX missing in C++ Program
Date: Mon, 24 Dec 2012 09:51:59 +0000

 UINT*_MAX and stdint.h are governed by the C99 standard (Section
 7.18). A footnote in that that section states that "C++
 implementations should define these macros only when
 __STDC_LIMIT_MACROS is defined before <stdint.h> is included."  The
 system headers in FreeBSD and many other implementations follow this
 recommendation.  If you want to use these macros in C++ code
 unconditionally, then you should include <cstdint> instead, as
 described in the C++11 standard ( the cstdint.syn section in Chapter
 18).  You probably ought to be doing this anyway.
 
 b.

From: "b.f." <bf1783@googlemail.com>
To: bug-followup@freebsd.org, Robin Carey <robin.carey1@googlemail.com>
Cc:  
Subject: Re: misc/174549: UINT64_MAX missing in C++ Program
Date: Wed, 26 Dec 2012 21:02:35 +0000

 On 12/26/12, Robin Carey <robin.carey1@googlemail.com> wrote:
 > Dear bf,
 >
 > I tried defining
 >
 > # define  __STDC_LIMIT_MACROS
 >
 > before the <stdint.h> inclusion (as you suggested), and it made no
 > difference - the error still occurs.
 >
 >
 > If you look at what gets included by <stdint.h>, you will see that that
 > definition is made in
 >
 > <sys/cdefs.h>
 >
 > anyway .... or that is what it looks like to me .... so it looks likes the
 > system makes that definition by
 > default (in which case there is no need to define it manually in the source
 > code).
 
 Only if you are compiling in C++11 mode (most compilers don't use this
 mode except when it is specifically requested, because it is so new,
 and is rarely fully supported).  The  is because the requirement that
 some of these standard C definitions be hidden from C++ code except
 when __STDC_LIMIT_MACROS and/or  __STDC_CONSTANT_MACROS is/are defined
 was removed from the C11 standard, and an explicit note was added to
 the C++11 standard  that the __STDC* macros are not to be considered
 when including <cstdint>, so some implementations have taken this as
 license to disregard them entirely in C++11 mode:
 
 http://svnweb.FreeBSD.org/base?view=revision&amp;revision=227475
 http://svnweb.FreeBSD.org/base?view=revision&amp;revision=227478
 
 I don't have a live system running FreeBSD 9*, but on -CURRENT a
 simple program like:
 
 #include <stdint.h>
 
 #ifdef UINT64_MAX
 #error UINT64_MAX is defined
 #else
 #error UINT64_MAX isn't defined
 #endif
 
 int main(void)
 {
 return (0);
 }
 
 behaves as expected:
 
 # c++ -Wall -Wextra -std=c++98 -o t1 test1.cc
 test1.cc:6:2: error: UINT64_MAX isn't defined
 #error UINT64_MAX isn't defined
  ^
 1 error generated.
 ret 1
 # c++ -Wall -Wextra -std=c++98 -D__STDC_LIMIT_MACROS -o t1 test1.cc
 test1.cc:4:2: error: UINT64_MAX is defined
 #error UINT64_MAX is defined
  ^
 1 error generated.
 ret 1
 # c++ -Wall -Wextra -std=c++11 -o t1 test1.cc
 test1.cc:4:2: error: UINT64_MAX is defined
 #error UINT64_MAX is defined
  ^
 1 error generated.
 ret 1
 
 Also, in 9.1, I see in src/sys/sys/stdint.h (installed as
 /usr/include/stdint.h):
 
 35#include <machine/_stdint.h>
 
 and in the machine-dependent headers -- for example, in
 src/sys/i386/include/_stdint.h
 , which is installed as /usr/include/machine/_stdint.h on i386(on
 -CURRENT there is one more remove, because some of the i386 and amd64
 headers have been unified):
 
 60#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS)
 ...
 82#define UINT64_MAX      0xffffffffffffffffULL
 
 So are you sure you haven't overlooked something?
 
 b.

From: Robin Carey <robin.carey1@googlemail.com>
To: bf1783@gmail.com, bug-followup@freebsd.org
Cc:  
Subject: Re: misc/174549: UINT64_MAX missing in C++ Program
Date: Sat, 29 Dec 2012 20:03:54 +0000

 --089e0122a8969c795b04d2034783
 Content-Type: multipart/alternative; boundary=089e0122a8969c795804d2034781
 
 --089e0122a8969c795804d2034781
 Content-Type: text/plain; charset=ISO-8859-1
 
 Dear Brendan & bug-followup,
 
 Re: Bug: misc/174549
 
 I have discovered what was causing the problem.
 I am not sure if this is a bug or not since it relates to the
 double-inclusion of <stdint.h>.
 
 To reproduce the bug, download "cp2.tgz" (tar archive; gzipped):
 
 http://www.leopard.uk.com/CP
 
 Then apply the attached diffs (to 2 files; Counter128.h and test.cxx). The
 commands used to generate
 the diff files are, i.e. "diff test.cxx test.cxx.ORIG" and "diff
 Counter128.h Counter128.h.ORIG".
 
 You will then find that the following command fails with previously
 reported error:
 
 "g++ -Wall test.cxx -lcrypto"
 
 -------
 
 The only reason I discovered what was causing the problem was because I
 just recently
 released Version 2 of my Cipher-Packet software (and in the process of
 doing that
 cleaned up "test.cxx" and removed the redundant <stdint.h> inclusion that
 was in there from
 previous coding/testing/etc).
 
 Sorry if I have wasted anybodys time.
 
 -- 
 Sincerely,
 
 Robin Carey BSc
 
 --089e0122a8969c795804d2034781--
 --089e0122a8969c795b04d2034783
 Content-Type: application/octet-stream; name="test.cxx.diff"
 Content-Disposition: attachment; filename="test.cxx.diff"
 Content-Transfer-Encoding: base64
 X-Attachment-Id: f_hbb6dgsj0
 
 MmQxCjwgIyBpbmNsdWRlICA8c3RkaW50Lmg+Cg==
 --089e0122a8969c795b04d2034783
 Content-Type: application/octet-stream; name="Counter128.h.diff"
 Content-Disposition: attachment; filename="Counter128.h.diff"
 Content-Transfer-Encoding: base64
 X-Attachment-Id: f_hbb6dpxi1
 
 NDJjNDIKPCAjIGRlZmluZSAgX19TVERDX0xJTUlUX01BQ1JPUwotLS0KPiAvLyMgZGVmaW5lICBf
 X1NURENfTElNSVRfTUFDUk9TCg==
 --089e0122a8969c795b04d2034783--

From: "b.f." <bf1783@googlemail.com>
To: Robin Carey <robin.carey1@googlemail.com>
Cc: bug-followup@freebsd.org
Subject: Re: misc/174549: UINT64_MAX missing in C++ Program
Date: Sun, 30 Dec 2012 03:13:19 +0000

 On 12/29/12, Robin Carey <robin.carey1@googlemail.com> wrote:
 > Dear Brendan & bug-followup,
 
 > Sorry if I have wasted anybodys time.
 
 Don't worry about it: it happens.  I'm glad to hear that you have
 solved your problem.
 
 Happy Holidays,
                              b.
State-Changed-From-To: open->closed 
State-Changed-By: linimon 
State-Changed-When: Sun Dec 30 03:29:25 UTC 2012 
State-Changed-Why:  
Closed at submitter's request. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=174549 
>Unformatted:
