From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6820 invoked by alias); 5 May 2011 21:50:45 -0000 Received: (qmail 6784 invoked by uid 22791); 5 May 2011 21:50:44 -0000 X-SWARE-Spam-Status: No, hits=-2.7 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 05 May 2011 21:50:30 +0000 From: "alexis.menard at openbossa dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/48891] New: std functions conflicts with C functions when building with c++0x support. X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: alexis.menard at openbossa dot org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Date: Thu, 05 May 2011 21:50:00 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-05/txt/msg00484.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D48891 Summary: std functions conflicts with C functions when building with c++0x support. Product: gcc Version: 4.6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: alexis.menard@openbossa.org Created attachment 24193 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=3D24193 Small test case. Hello, I'm not sure it's a real bug (though that example builds fine with gcc 4.5.= 0) but at least perhaps I'll get help. Consider : #include #include #include using namespace std; int main(int argc, char** argv) { double number =3D 0; if (isnan(number)) { printf("Nan\n"); } return 0; } and build it with : g++ main.cpp -std=3Dc++0x -std=3Dgnu++0x -o test It fails to compile :=20 main.cpp: In function =E2=80=98int main(int, char**)=E2=80=99: main.cpp:10:21: error: call of overloaded =E2=80=98isnan(double&)=E2=80=99 = is ambiguous main.cpp:10:21: note: candidates are: /usr/include/bits/mathcalls.h:235:1: note: int isnan(double) /usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.0/../../../../include/c++/4.6.0/c= math:558:3: note: bool std::isnan(long double) /usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.0/../../../../include/c++/4.6.0/c= math:554:3: note: bool std::isnan(double) /usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.0/../../../../include/c++/4.6.0/c= math:550:3: note: bool std::isnan(float) If I deactivate the c++0x support it works. The real issue is that the c++0x standard removes the prohibition on C++ headers declaring C names in the global namespace. The problem here is that math.h is included therefore the declarations are in the global namespace. I'm not really sure how the compiler can solve that but this new "feature" = of c++0x seems to be very annoying. I could solve it by not using namespace std but let say the project is huge, it will requires lot of modifications. Basically any time you use using namespace std, you may have conflicts with= the underlaying C libraries, it's even more annoying with your own namespace because your functions can conflict with all the stuff in the global namesp= ace put by C libraries and it's very common in a cpp file to use "using namespa= ce foo;" Any suggestions on how I could "workaround" that?