Bug 55682 - erf, erfc placed in global namespace by <cmath> without --std=c++11
Summary: erf, erfc placed in global namespace by <cmath> without --std=c++11
Status: RESOLVED WORKSFORME
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: unknown
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-12-14 07:55 UTC by Nico
Modified: 2012-12-14 10:47 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nico 2012-12-14 07:55:24 UTC
The functions erf, erfc are part of the C++11 standard. They are already implemented in <math.h> and available in the global namespace after #including it.
However, they are missing from <cmath>.
Comment 1 Nico 2012-12-14 08:26:40 UTC
Apparently, when compiled with --std=c++11, the erf(c) functions are correctly placed in the std:: namespace. Otherwise, they're in the global namespace (this is math.h's behavior).
Comment 2 Paolo Carlini 2012-12-14 10:00:46 UTC
Then what? This is expected and conforming.
Comment 3 Nico 2012-12-14 10:37:19 UTC
(In reply to comment #2)
> Then what? This is expected and conforming.

Oh, it just struck me as funny that cmath imports std::exp and friends, but not std::erf. I filed the bug since apparently not only I was confused (cf. http://gcc.gnu.org/ml/gcc-help/2012-12/msg00043.html).

Anyhow. I suppose libstdc++ is consistent in that cmath doesn't provide more than what is in the standard.
Comment 4 Jonathan Wakely 2012-12-14 10:44:25 UTC
(In reply to comment #3)
> Oh, it just struck me as funny that cmath imports std::exp and friends, but not
> std::erf.

std::exp is in C++98, std::erf isn't.

As I said on the list, I assumed you were using -std=c++11 when you said it wasn't in <cmath>
Comment 5 Nico 2012-12-14 10:47:05 UTC
Bottom line: problem solved. I just compile my code with -std=c++11 and get std::erf immediately.
Thanks for the clarification!