
On Nov 22, 2007, at 3:22 AM, Joaquín Mª López Muñoz wrote:
Joaquín Mª López Muñoz ha escrito:
"K. Noel Belcourt" ha escrito:
On Nov 16, 2007, at 5:10 AM, Joaquín Mª López Muñoz wrote:
John Maddock ha escrito: [...]
In foo::swap the local declaration of the member function "swap" hides any occurances of swap in the outer scope, and the using declaration behaves "as if" std::swap were imported into the *enclosing namespace*, which would still be hidden... and yet I can't believe that this simple idiom isn't actually legal ! :-) And indeed all the other compilers I tested do compile this OK.
Ouch, didn't think about name hiding... this is why I love C++ :-/
Now I don't know either whether the code is legal or not. Anyway, if I changed foo::swap to foo::swop the code would be undoubtedly legal then, right?
Noel, would you please try the attached variation?
Compiles fine with vacpp-8.0, no errors or warnings.
Ok, thanks for your help! I think I'll change then my code to avoid the name hiding thing, hopefully you'll see multi_index tests go green for vacpp-8.0 in the next cycle.
I changed some code inside Boost.MultiIndex so as to move the using std::swap decl out of the name-hiding scope (http://svn.boost.org/trac/boost/ changeset/41220 ) but the error happens the same (http://tinyurl.com/256p2t ). So I guess there are still cases where the compiler handles this wrong even if no name-hiding problems are present.
Noel, could you please try the following variation of the test snippet, which tries to mimic as closely as possible the structure of the failing code? Thank you!
xlC fsudba3.cpp "fsudba3.cpp", line 12.10: 1540-0256 (S) A parameter of type "foo<int> &" cannot be initialized with an expression of type "int". "fsudba3.cpp", line 12.10: 1540-1205 (I) The error occurred while converting to parameter 1 of "foo<int>::swap(foo<int> &)". "fsudba3.cpp", line 9.8: 1540-0700 (I) The previous message was
Okay, here it is. produced while processing "foo<int>::swap_(foo<int> &)". "fsudba3.cpp", line 8.21: 1540-0700 (I) The previous message was produced while processing "foo<int>::swap(foo<int> &)". "fsudba3.cpp", line 25.8: 1540-0700 (I) The previous message was produced while processing "main()". -- Noel