Boost logo

Boost :

From: Ruediger Berlich (ruediger.berlich_at_[hidden])
Date: 2008-08-05 18:43:21


Hi John,
I get no warnings whatsoever for this code with gcc 4.3.1 on an OpenSUSE
11 / 64 bit box.
Best, Ruediger

John Maddock wrote:

> Folks I have a large amount of code that generates warnings of the kind:
>
> t.cpp:6: warning: shadowing built-in function `double
> std::acos(double)'
>
> Actually many thousands of these warnings when building with g++ -Wshadow
> :-(
>
> Normally I would just fix the code, but in this case I don't see how, I
> have code that looks like:
>
> #include <cmath>
>
> template <class T>
> T f(T v)
> {
> // We want acos found via ADL in case T is a class type:
> using std::acos;
> return acos(v);
> }
>
> int main()
> {
> f(2.0);
> return 0;
> }
>
> Which just on it's own produces:
>
> $ g++ -I. -Wall -Wshadow -c t.cpp 2>&1 | less
>
> t.cpp: In function `void f(T)':
> t.cpp:6: warning: shadowing built-in function `double std::acos(double)'
> t.cpp: In function `void f(T) [with T = double]':
> t.cpp:12: instantiated from here
> t.cpp:6: warning: shadowing built-in function `double std::acos(double)'
> t.cpp:12: instantiated from here
>
> But I can't see any other way to code this... certainly using a "using
> namespace std;" in place of the "using std::functionname;" is *not* a
> valid fix (it can lead to lookup ambiguities).
>
> Any ideas folks?
>
> Thanks, John.
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk