[config][vacpp 8.0] BOOST_FUNCTION_SCOPE_USING_DECLARATION_BREAKS_ADL should be defined?

Hello, the errors shown at http://tinyurl.com/2ao9tf and other tests lead me to believe that IBM Visual Age v8.0 has a problem with using declarations at function scope and ADL, yet the macro BOOST_FUNCTION_SCOPE_USING_DECLARATION_BREAKS_ADL is not defined for this compiler. I'd be grateful if someone with access to vacpp 8.0 (like the maintainer of Sandia-AIX regression tests) would: 1. Try libs/config/test/no_using_breaks_adl_pass.cpp. 2. If the latter passes, try the attached test fsudba.cpp, which exercises an alternative way in which using declarations at function scope can break ADL. Thank you! Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

On Nov 15, 2007, at 4:09 PM, JOAQUIN LOPEZ MU?Z wrote:
Passes
Here's the output of :
xlC fsudba.cpp
"fsudba.cpp", line 11.28: 1540-0256 (S) A parameter of type "foo<int> &" cannot be initialized with an expression of type "int". "fsudba.cpp", line 11.28: 1540-1205 (I) The error occurred while converting to parameter 1 of "foo<int>::swap(foo<int> &)". "fsudba.cpp", line 8.14: 1540-0700 (I) The previous message was produced while processing "foo<int>::swap(foo<int> &)". "fsudba.cpp", line 24.8: 1540-0700 (I) The previous message was produced while processing "main()". -- Noel

"K. Noel Belcourt" ha escrito:
Bingo :) John, do you think then that BOOST_FUNCTION_SCOPE_USING_DECLARATION_BREAKS_ADL should be defined for __IBMCPP__<=800? Also, if you think it's appropriate I can add the test above to libs/config/test/boost_no_using_breaks_adl.ipp. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

Joaquín Mª López Muñoz wrote:
Hmmm, the interesting thing is, I'm having a hard time convincing myself that this code is legal, I'm cc'ing our friendly IBM compiler expert in case he can shed light on this. Consider the code again: #include <algorithm> template<typename T> struct foo { T t; foo():t(0){} void swap(foo& x) { using std::swap; swap(t,x.t); } }; template<typename T> void swap(foo<T>& x,foo<T>& y) { x.swap(y); } int main() { foo<int> x,y; x.swap(y); } 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. Whatever the issue is, it's not really the same as BOOST_FUNCTION_SCOPE_USING_DECLARATION_BREAKS_ADL, but I'm not sure what it is the same as yet :-( On the other hand extending the scope of BOOST_FUNCTION_SCOPE_USING_DECLARATION_BREAKS_ADL might be the easiest workaround. At present, confused yours, John.

John Maddock ha escrito:
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? Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

This compiles fine with the version 9 compiler. I think the code is legal (haven't spent great deal of time confirming) because the too swap()'s are should be available for overload resolution with std::swap winning. A very simple simple fix is to change the call to swap to be qualified. For example: void swap(foo& x) { std::swap(t,x.t); } -- Sean Perry Compiler Development IBM Canada Lab (905)-413-6031 (tie 313-6031), fax (905)-413-4839 Joaquín Mª López Muñoz <joaquin@tid.es> To Sent by: boost@lists.boost.org boost-bounces@lis cc ts.boost.org Subject Re: [boost] [config][vacpp8.0] 11/16/07 07:10 AM BOOST_FUNCTION_SCOPE_USING_DECLARAT ION_BREAKS_ADL should be defined? Please respond to boost@lists.boost .org John Maddock ha escrito:
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? Joaquín M López Muñoz Telefónica, Investigación y Desarrollo (See attached file: fsudba2.cpp) _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

"K. Noel Belcourt" ha escrito:
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. As for whether the original test (with name hiding) is legal or not, well, I don't really know, but I'd love to have the opinion of some C++ guru. Thank you, Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

Joaquín Mª López Muñoz ha escrito:
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! Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

On Nov 22, 2007, at 3:22 AM, Joaquín Mª López Muñoz wrote:
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

"K. Noel Belcourt" ha escrito:
Ok, so we've got a case again. John, let me re-ask you about what we should do regarding this compiler bug. For your reference, the offending code does not involve name hiding anymore: #include <algorithm> template<typename T> struct foo { T t; foo():t(0){} void swap(foo& x){swap_(x);} void swap_(foo& x) { using std::swap; swap(t,x.t); } }; template<typename T> void swap(foo<T>& x,foo<T>& y) { x.swap(y); } int main() { foo<int> x,y; x.swap(y); } Of course there's no big problem if it's decided that this shouldn't be covered by BOOST_FUNCTION_SCOPE_USING_DECLARATION_BREAKS_ADL, but I think the bug qualifies as a reasonable extension for the concept covered by the macro. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

This code does have the name hiding.overload resolution issues still. Can you change the call to swap so you use "std::swap(t.x, t.y)" instead of the using declaration and "swap(t.x,t.y)". The following compiles for me: #include <algorithm> template<typename T> struct foo { T t; foo():t(0){} void swap(foo& x){swap(x);} void swap(foo& x) { std::swap(t,x.t); } }; template<typename T> void swap(foo<T>& x,foo<T>& y) { x.swap(y); } int main() { foo<int> x,y; x.swap(y); } -- Sean Perry Compiler Development IBM Canada Lab (905)-413-6031 (tie 313-6031), fax (905)-413-4839 Joaquín Mª López Muñoz <joaquin@tid.es> To Sent by: boost@lists.boost.org boost-bounces@lis cc ts.boost.org Subject [boost] 11/22/2007 01:28 Re:[config][vacpp8.0]BOOST_FUNCTION PM _SCOPE_USING_DECLARATION_BREAKS_ADL should be defined? Please respond to boost@lists.boost .org "K. Noel Belcourt" ha escrito:
Ok, so we've got a case again. John, let me re-ask you about what we should do regarding this compiler bug. For your reference, the offending code does not involve name hiding anymore: #include <algorithm> template<typename T> struct foo { T t; foo():t(0){} void swap(foo& x){swap_(x);} void swap_(foo& x) { using std::swap; swap(t,x.t); } }; template<typename T> void swap(foo<T>& x,foo<T>& y) { x.swap(y); } int main() { foo<int> x,y; x.swap(y); } Of course there's no big problem if it's decided that this shouldn't be covered by BOOST_FUNCTION_SCOPE_USING_DECLARATION_BREAKS_ADL, but I think the bug qualifies as a reasonable extension for the concept covered by the macro. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

----- Mensaje original ----- De: Sean Perry <perry@ca.ibm.com> Fecha: Jueves, Noviembre 22, 2007 8:28 pm Asunto: Re: [boost] [config][vacpp8.0] BOOST_FUNCTION_SCOPE_USING_DECLARATION_BREAKS_ADL should be defined? Para: boost@lists.boost.org
This code does have the name hiding.overload resolution issues still.
I don't see how name hiding is involved here: ... void swap(foo& x){swap_(x);} void swap_(foo& x) { using std::swap; swap(t,x.t); } ... Note that swap(t,x.t) is called inside swap_, with "_" suffix.
Can you change the call to swap so you use "std::swap(t.x, t.y)" instead of the using declaration and "swap(t.x,t.y)".
This wouldd avoid using ADL, which is what the problem's all about.
Maybe you've pasted your code wrong, cause the above redeclares foo::swap(). Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

Joaquín Mª López Muñoz wrote:
Yes it does: foo::swap is still in the current scope :-( Making swap_ a non-member function would fix it (I hope!): template <class T> void call_swap(T& a, T& b) { using std::swap; swap(a, b); } template<typename T> struct foo { T t; foo():t(0){} void swap(foo& x){call_swap(t, x.t);} }; Does this help? John.

----- Mensaje original ----- De: John Maddock <john@johnmaddock.co.uk> Fecha: Viernes, Noviembre 23, 2007 8:05 pm Asunto: Re: [boost][config][vacpp8.0] BOOST_FUNCTION_SCOPE_USING_DECLARATION_BREAKS_ADL should be defined? Para: boost@lists.boost.org
Oh my, you're right. I can't seem to get this straight. Sorry for the noise, I'll try the approach you suggest and see if vacpp 8.0 finally accepts that. Thank you, Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
participants (5)
-
"JOAQUIN LOPEZ MU?Z"
-
Joaquín Mª López Muñoz
-
John Maddock
-
K. Noel Belcourt
-
Sean Perry