[hash][msvc 8.0] <boost/functional/hash/detail/float_functions.hpp> issuing a using namespace std directive?

If I compile the following wih MSVC++ 8.0: #include <list> typedef list<int> foo; the compiler complains, fairly enough, with some syntax error due to the fact that there's no "list" in the global namespace (we missed a prefixing std::). But if I now try this: #include <boost/functional/hash/detail/float_functions.hpp> #include <list> typedef list<int> foo; compilation succeeds! Somehow, <boost/functional/hash/detail/float_functions.hpp> is importing namespace std into the global namespace, presumably with a using directive. I tried to examine the offending header an saw no obvious using directive to blame, so I hope someone more knowledgeable can take a look at this problem. Thank you, Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

2009/6/17 JOAQUIN M. LOPEZ MUÑOZ <joaquin@tid.es>:
I tried to examine the offending header an saw no obvious using directive to blame, so I hope someone more knowledgeable can take a look at this problem.
This also compiles: #include <list> namespace bar { using namespace std; template <typename x> struct xxx {}; } typedef list<int> foo; So, I'll try to rearrange it so that it avoids doing anything like that, or uses an alternative implementation for Visual C++. Or something. thanks, Daniel

On Wed, Jun 17, 2009 at 09:53:02PM +0200, JOAQUIN M. LOPEZ MUÑOZ wrote:
If I compile the following wih MSVC++ 8.0: [...] compilation succeeds! Somehow, <boost/functional/hash/detail/float_functions.hpp> is importing namespace std into the global namespace, presumably with a using directive.
Yeah, I've tripped over this MSVC bug as well. 'using namespace' in namespace scope 'leaks' out into file scope. It's pretty annoying because it still occurs over header file boundaries. The bug is still present in VC9, I believe, but I haven't tried 10 yet. (Microsoft knows it exists but declines to fix it in old compilers.) -- Trends on the internet are larger than they appear. http://surreal.istic.org/ Why did you resign?

Daniel Hulme escribió:
On Wed, Jun 17, 2009 at 09:53:02PM +0200, JOAQUIN M. LOPEZ MUÑOZ wrote:
If I compile the following wih MSVC++ 8.0:
[...]
compilation succeeds! Somehow, <boost/functional/hash/detail/float_functions.hpp> is importing namespace std into the global namespace, presumably with a using directive.
Yeah, I've tripped over this MSVC bug as well. 'using namespace' in namespace scope 'leaks' out into file scope. It's pretty annoying because it still occurs over header file boundaries. The bug is still present in VC9, I believe, but I haven't tried 10 yet. (Microsoft knows it exists but declines to fix it in old compilers.)
Hi Daniel. Is this officially reported? Do you know if there's some bug ID or URL we can track? Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

Yeah, I've tripped over this MSVC bug as well. 'using namespace' in namespace scope 'leaks' out into file scope. It's pretty annoying because it still occurs over header file boundaries. The bug is still present in VC9, I believe, but I haven't tried 10 yet. (Microsoft knows it exists but declines to fix it in old compilers.)
I tried with VC10, the bug is no longer present -- at least, #include <list> namespace bar { using namespace std; template <typename x> struct xxx {}; } typedef list<int> foo; results in a compile error due to a missing identifier before < in the typedef list<int> line. Cheers, Anteru

Anteru escribió:
I tried with VC10, the bug is no longer present -- at least, #include <list>
namespace bar { using namespace std; template <typename x> struct xxx {}; }
typedef list<int> foo; results in a compile error due to a missing identifier before < in the typedef list<int> line.
Can you try this? #include <list> #include <boost/functional/hash.hpp> typedef list<int> foo; Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

I just tried it on VC10 (beta1), and the original problem does happen if <boost/functional/hash/hash.hpp> is included in a precompiled header and <list> is included outside it. It's ok if you don't use precompiled headers, and interestingly the new intellisense (which uses the EDG front end instead of the MS one) flags it as an error even though the actual compiler accepts it. -- View this message in context: http://www.nabble.com/-hash--msvc-8.0--%3Cboost-functional-hash-detail-float... Sent from the Boost - Dev mailing list archive at Nabble.com.

Richard Webb schrieb:
I just tried it on VC10 (beta1), and the original problem does happen if <boost/functional/hash/hash.hpp> is included in a precompiled header and <list> is included outside it.
It's ok if you don't use precompiled headers, and interestingly the new intellisense (which uses the EDG front end instead of the MS one) flags it as an error even though the actual compiler accepts it. Did you report an error via Connect? If not, I'll go ahead and file one, as this should really get tracked properly.
Cheers, Anteru

Anteru-2 wrote:
Did you report an error via Connect? If not, I'll go ahead and file one, as this should really get tracked properly.
Cheers, Anteru
No, i haven't reported the problem. Thanks, Richard Webb -- View this message in context: http://www.nabble.com/-hash--msvc-8.0--%3Cboost-functional-hash-detail-float... Sent from the Boost - Dev mailing list archive at Nabble.com.

I just tried it on VC10 (beta1), and the original problem does happen if <boost/functional/hash/hash.hpp> is included in a precompiled header and <list> is included outside it.
It's ok if you don't use precompiled headers, and interestingly the new intellisense (which uses the EDG front end instead of the MS one) flags it as an error even though the actual compiler accepts it. I can't reproduce it. I put <boost/functional/hash/hash.hpp> into a
Richard Webb schrieb: precompiled header, and then I try #include "precompiled.h" #include <list> typedef list<int> foo; int main () {} which fails, as expected. What exactly did you try? Cheers, Anteru

2009/6/19 Anteru <newsgroups@catchall.shelter13.net>:
I can't reproduce it. I put <boost/functional/hash/hash.hpp> into a precompiled header, and then I try
#include "precompiled.h"
#include <list> typedef list<int> foo;
int main () {}
which fails, as expected. What exactly did you try?
If you're using trunk, then it's been fixed (hopefully). If you're using a released version of boost then that doesn't include the change that caused this. The problem is still present in the release branch: http://svn.boost.org/svn/boost/branches/release/boost/functional/hash/detail... Or trunk from a few days ago. Daniel

2009/6/19 Daniel James <daniel_james@fmail.co.uk>:
2009/6/19 Anteru <newsgroups@catchall.shelter13.net>:
which fails, as expected. What exactly did you try?
If you're using trunk, then it's been fixed (hopefully). [snip]
Oh sorry, you already know all of that. I'm not paying close enough attention. Daniel

Daniel James schrieb:
If you're using trunk, then it's been fixed (hopefully). If you're using a released version of boost then that doesn't include the change that caused this. I tried Boost 1.39, and I couldn't repro with that. So what exactly did you try?
I also tried a simplified example, but no matter what I do in the precompiled header, it always complains about the missing symbol, so I can't get it to leak outside the namespace. Cheers, Anteru

Anteru-2 wrote:
I tried Boost 1.39, and I couldn't repro with that. So what exactly did you try?
I tried 2 things - including the hash header in a PCH and <list> in the cpp file, and a proper project that hits the problem i mentioned before with system/error_code.cpp. As Daniel says though, the problem doesn't occur in either 1.39 or the current Trunk (i was testing with a slightly older copy of Trunk. Not sure exactly what date it's from). -- View this message in context: http://www.nabble.com/-hash--msvc-8.0--%3Cboost-functional-hash-detail-float... Sent from the Boost - Dev mailing list archive at Nabble.com.

2009/6/18 Daniel Hulme <st@istic.org>:
Yeah, I've tripped over this MSVC bug as well. 'using namespace' in namespace scope 'leaks' out into file scope. It's pretty annoying because it still occurs over header file boundaries. The bug is still present in VC9, I believe, but I haven't tried 10 yet. (Microsoft knows it exists but declines to fix it in old compilers.)
When I tested it, it didn't affect VC9 although that might just be for this specific case. I've changed it so that there aren't any templates in the same namespace as the 'using namespace' which I think fixes the problem. If not, I can use an alternative implementation for Visual C++. Daniel

Daniel James wrote:
When I tested it, it didn't affect VC9
You get the same thing happening in VC9(SP1) if you put #include <boost/functional/hash/hash.hpp> in a precompiled header and <list> in a cpp file that includes it. I recently ran into a similar issue, where i had #define BOOST_ERROR_CODE_HEADER_ONLY #include <boost/system/error_code.hpp> in a cpp file and the hash header in the precompiled header, which causes the error boost\libs\system\src\error_code.cpp(267) : error C2872: 'invalid_argument' : ambiguous symbol could be 'boost\system\error_code.hpp(85) : boost::system::errc::errc_t invalid_argument' or '\microsoft visual studio 9.0\vc\include\stdexcept(76) : std::invalid_argument' Maybe a bit of an odd case, but confusing in any case. In any case, it seems ok with the current trunk :) -- View this message in context: http://www.nabble.com/-hash--msvc-8.0--%3Cboost-functional-hash-detail-float... Sent from the Boost - Dev mailing list archive at Nabble.com.

2009/6/18 Richard Webb <richard.webb@boldonjames.com>:
Daniel James wrote:
When I tested it, it didn't affect VC9
You get the same thing happening in VC9(SP1) if you put #include <boost/functional/hash/hash.hpp> in a precompiled header and <list> in a cpp file that includes it.
OK, I might have run it with VC10 on accident. I've got too many compilers installed.
In any case, it seems ok with the current trunk :)
I think it's okay now, but I'll wait until all the testers have run before merging to release. Although we don't seem to have anyone testing with anything older than Visual C++ 9 on trunk. I still might write a special case for Visual C++ that doesn't use 'using namespace' outside of a function, just to be on the safe side. thanks, Daniel

Daniel James wrote:
I think it's okay now, but I'll wait until all the testers have run before merging to release. Although we don't seem to have anyone testing with anything older than Visual C++ 9 on trunk.
I apologize for that. I've been running nightly tests with msvc 7.1 on both trunk and branches/release, but there has been an error processing the trunk results. I just discovered the error, and I don't know how long it has been going on. New MSVC 7.1 trunk results will hopefully be up tomorrow morning. David

2009/6/24 David Walthall <walthall@stanfordalumni.org>:
I apologize for that. I've been running nightly tests with msvc 7.1 on both trunk and branches/release, but there has been an error processing the trunk results. I just discovered the error, and I don't know how long it has been going on. New MSVC 7.1 trunk results will hopefully be up tomorrow morning.
No need to apologize. And thanks for running the tests, they're a great help. I've now merged all the changes to release. Daniel
participants (7)
-
Anteru
-
Daniel Hulme
-
Daniel James
-
David Walthall
-
JOAQUIN M. LOPEZ MUÑOZ
-
joaquin@tid.es
-
Richard Webb