From nobody@FreeBSD.org  Thu Jun 10 15:34:23 2004
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 72B3916A4CE
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 10 Jun 2004 15:34:23 +0000 (GMT)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 305B943D1D
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 10 Jun 2004 15:34:23 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.12.11/8.12.11) with ESMTP id i5AFYExS071938
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 10 Jun 2004 15:34:14 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.12.11/8.12.11/Submit) id i5AFYEr8071937;
	Thu, 10 Jun 2004 15:34:14 GMT
	(envelope-from nobody)
Message-Id: <200406101534.i5AFYEr8071937@www.freebsd.org>
Date: Thu, 10 Jun 2004 15:34:14 GMT
From: Jack Lloyd <lloyd@randombit.net>
To: freebsd-gnats-submit@FreeBSD.org
Subject: C++ can't compile anything with -ansi
X-Send-Pr-Version: www-2.3

>Number:         67798
>Category:       gnu
>Synopsis:       C++ can't compile anything with -ansi
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jun 10 15:40:20 GMT 2004
>Closed-Date:    Thu Jun 10 19:15:14 GMT 2004
>Last-Modified:  Fri Jun 11 07:10:21 GMT 2004
>Originator:     Jack Lloyd
>Release:        5.1
>Organization:
>Environment:
FreeBSD synacklabs01 5.1-RELEASE FreeBSD 5.1-RELEASE #0: Mon Mar  8 17:52:43 CST 2004     root@:/usr/src/sys/i386/compile/GENERIC  i386
>Description:
Essentially using any C++ headers and compiling with the -ansi flag fails on FreeBSD 5.1, and probably most 5- releases (it was reported on the GCC list March 2003). I haven't tested 5.2/5.2.1, if this has been fixed please just close + let me know it's OK now.

There is a fairly complete analysis, including a proposed fix, in this thread from last year:
   http://gcc.gnu.org/ml/libstdc++/2003-03/msg00329.html

Including virtually any standard ISO C++ header (iostream, string, cstdlib) and compiling with -ansi causes compilation failure due to missing decls in libc's headers.

>How-To-Repeat:
synacklabs01% g++ -v
Using built-in specs.
Configured with: FreeBSD/i386 system compiler
Thread model: posix
gcc version 3.2.2 [FreeBSD] 20030205 (release)

synacklabs01% cat test.cpp 
#include <iostream>

int main()
{
  std::cout << "Hello world" << std::endl;
}

synacklabs01% g++ -ansi test.cpp
In file included from /usr/include/g++/bits/fpos.h:45,
                 from /usr/include/g++/iosfwd:46,
                 from /usr/include/g++/ios:44,
                 from /usr/include/g++/ostream:45,
                 from /usr/include/g++/iostream:45,
                 from test.cpp:1:
/usr/include/g++/cwchar:229: `wcstoll' not declared
/usr/include/g++/cwchar:230: `wcstoull' not declared
/usr/include/g++/cwchar:236: `wcstoll' not declared
/usr/include/g++/cwchar:237: `wcstoull' not declared
In file included from /usr/include/g++/bits/stl_algobase.h:67,
                 from /usr/include/g++/memory:54,
                 from /usr/include/g++/string:48,
                 from /usr/include/g++/bits/localefwd.h:49,
                 from /usr/include/g++/ios:48,
                 from /usr/include/g++/ostream:45,
                 from /usr/include/g++/iostream:45,
                 from test.cpp:1:
/usr/include/g++/cstdlib:138: `lldiv_t' not declared
/usr/include/g++/cstdlib:148: syntax error before `(' token
In file included from /usr/include/g++/bits/stl_algobase.h:67,
                 from /usr/include/g++/memory:54,
                 from /usr/include/g++/string:48,
                 from /usr/include/g++/bits/localefwd.h:49,
                 from /usr/include/g++/ios:48,
                 from /usr/include/g++/ostream:45,
                 from /usr/include/g++/iostream:45,
                 from test.cpp:1:
/usr/include/g++/cstdlib:125:1: unterminated #if
/usr/include/g++/cstdlib:44:1: unterminated #ifndef
In file included from /usr/include/g++/memory:54,
                 from /usr/include/g++/string:48,
                 from /usr/include/g++/bits/localefwd.h:49,
                 from /usr/include/g++/ios:48,
                 from /usr/include/g++/ostream:45,
                 from /usr/include/g++/iostream:45,
                 from test.cpp:1:
/usr/include/g++/bits/stl_algobase.h:61:1: unterminated #ifndef
In file included from /usr/include/g++/string:48,
                 from /usr/include/g++/bits/localefwd.h:49,
                 from /usr/include/g++/ios:48,
                 from /usr/include/g++/ostream:45,
                 from /usr/include/g++/iostream:45,
                 from test.cpp:1:
/usr/include/g++/memory:49:1: unterminated #ifndef
In file included from /usr/include/g++/bits/localefwd.h:49,
                 from /usr/include/g++/ios:48,
                 from /usr/include/g++/ostream:45,
                 from /usr/include/g++/iostream:45,
                 from test.cpp:1:
/usr/include/g++/string:40:1: unterminated #ifndef
In file included from /usr/include/g++/ios:48,
                 from /usr/include/g++/ostream:45,
                 from /usr/include/g++/iostream:45,
                 from test.cpp:1:
/usr/include/g++/bits/localefwd.h:40:1: unterminated #ifndef
In file included from /usr/include/g++/ostream:45,
                 from /usr/include/g++/iostream:45,
                 from test.cpp:1:
/usr/include/g++/ios:39:1: unterminated #ifndef
In file included from /usr/include/g++/iostream:45,
                 from test.cpp:1:
/usr/include/g++/ostream:40:1: unterminated #ifndef
In file included from test.cpp:1:
/usr/include/g++/iostream:39:1: unterminated #ifndef
>Fix:
      
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: arved 
State-Changed-When: Thu Jun 10 19:14:48 GMT 2004 
State-Changed-Why:  
This is fixed in FreeBSD 5.2.1 with gcc 3.3 

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

From: David Schultz <das@FreeBSD.ORG>
To: Jack Lloyd <lloyd@randombit.net>
Cc: freebsd-gnats-submit@FreeBSD.ORG
Subject: Re: gnu/67798: C++ can't compile anything with -ansi
Date: Fri, 11 Jun 2004 00:02:16 -0700

 On Thu, Jun 10, 2004, Jack Lloyd wrote:
 > >Number:         67798
 > >Category:       gnu
 > >Synopsis:       C++ can't compile anything with -ansi
 [...]
 > Essentially using any C++ headers and compiling with the -ansi
 > flag fails on FreeBSD 5.1, and probably most 5- releases (it was
 > reported on the GCC list March 2003). I haven't tested 5.2/5.2.1,
 > if this has been fixed please just close + let me know it's OK now.
 
 It has been fixed, along with many other namespace issues that
 arose because libstdc++ didn't adapt to namespace changes induced
 by command line options.  From src/contrib/libstdc++/ChangeLog:
 
 2003-04-18  Loren J. Rittle  <ljrittle@acm.org>
 
         * config/os/bsd/freebsd/ctype_inline.h:  Support _M_table
         when so installed.
 
         * docs/html/17_intro/porting.texi (_GLIBCPP_USE_C99_CHECK): New macro.
         (_GLIBCPP_USE_C99_DYNAMIC): New macro.
         (_GLIBCPP_USE_C99_LONG_LONG_CHECK): New macro.
         (_GLIBCPP_USE_C99_LONG_LONG_DYNAMIC): New macro.
         * config/os/bsd/freebsd/os_defines.h (_GLIBCPP_USE_C99_CHECK):
         New macro.
         (_GLIBCPP_USE_C99_DYNAMIC): New macro.
         (_GLIBCPP_USE_C99_LONG_LONG_CHECK): New macro.
         (_GLIBCPP_USE_C99_LONG_LONG_DYNAMIC): New macro.
         * include/c_std/std_cstdlib.h: Use new macros.
         * include/c_std/std_cstdio.h: Use new macros.
         * include/c_std/std_cwchar.h: Use new macros.
 
 You now owe Loren a beer.  ;-)
>Unformatted:
