This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/29552] New: std::power() is not in the std namespace when including <ext/numeric>


Sees:
In <ext/numeric> power() is not declared in the std namespace, and the program
doesn't compile.

Expects:
power to be included in the <ext/numeric> namespace.

Source:
using namespace std;
#include <iostream>
#include <ext/numeric>

int main() {
  cout << power (2,30) << endl;
}

Command line Flag and Compiler error:
[brandon@c-71-60-104-243 testpower]$ make
make  all-am
make[1]: Entering directory `/home/brandon/testpower'
if g++ -DHAVE_CONFIG_H -I. -I. -I.     -g -O2 -MT testpower.o -MD -MP -MF
".deps/testpower.Tpo" -c -o testpower.o testpower.cpp; \
then mv -f ".deps/testpower.Tpo" ".deps/testpower.Po"; else rm -f
".deps/testpower.Tpo"; exit 1; fi
testpower.cpp: In function ?int main()?:
testpower.cpp:6: error: ?power? was not declared in this scope
make[1]: *** [testpower.o] Error 1
make[1]: Leaving directory `/home/brandon/testpower'
make: *** [all] Error 2
[brandon@c-71-60-104-243 testpower]$

The numeric power function that isn't included is described in this document.
http://www.sgi.com/tech/stl/power.html

Workaround, is to add a using __gnu_cxx::power;

using namespace std;
#include <iostream>
#include <ext/numeric>
using __gnu_cxx::power;

int main() {
  cout << power (2,30) << endl;
}

Version Info:
g++ (GCC) 4.1.1 20060525 (Red Hat 4.1.1-1)
2.6.18-1.2200.fc5 #1 Sat Oct 14 16:59:26 EDT 2006 i686 athlon i386 GNU/Linux
 -- Also happens in 3.2 compilers.

Works in included header:
#include <backward/algo.h>

-- Note: if this is a unfixed bug, can I write a patch? It is one of my life
long dreams to commit something to gcc.


-- 
           Summary: std::power() is not in the std namespace when including
                    <ext/numeric>
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: brandon at rioja dot us
 GCC build triplet: i686-redhat-linux-gnu
  GCC host triplet: i686-redhat-linux-gnu
GCC target triplet: i686-redhat-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29552


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]