Opened 12 years ago
Closed 12 years ago
#4193 closed Patches (invalid)
Multiple 'using' declarations in multi_index test
Reported by: | Chris Jefferson | Owned by: | Joaquín M López Muñoz |
---|---|---|---|
Milestone: | Boost 1.43.0 | Component: | multi_index |
Version: | Boost Release Branch | Severity: | Problem |
Keywords: | Cc: |
Description
The following simple patch removes some 'using std::swap' declarations in libs/multi_index/test/test_modifiers.cpp. Note that they are all in the same function under the same macro, and we do not remove the first one, so the code will function identically, but is now correct.
Fixes problem in clang and comeau.
Attachments (1)
Change History (8)
by , 12 years ago
Attachment: | test_modifiers.patch added |
---|
comment:1 by , 12 years ago
Component: | None → multi_index |
---|---|
Owner: | set to |
comment:2 by , 12 years ago
Hi Chris,
Can you please explain to me why having redundant using declarations is incorrect? I've just tested it in Comeau online and found no problems. For your reference, the test snippet was:
#include <algorithm> int main() { int x=0,y=0; using std::swap; swap(x,y); using std::swap; swap(x,y); }
comment:3 by , 12 years ago
Sorry, the reduced test I was using at comeau was not testing what I thought it was.
It is still the case that this code does not compile in clang, because of the repeated std::swaps, but it may be a fault in clang, which could be fixed rather than introducing an #ifdef or patch.
Will report back after further investigation
comment:4 by , 12 years ago
From Doug Gregor, it appears that clang is right to reject the current code:
Clang is correct; Comeau and g++ are wrong not to diagnose these errors. See C++ [namespace.udecl]p10:
A using-declaration is a declaration and can therefore be used repeatedly
where (and only where) multiple declarations are allowed.
follow-up: 6 comment:5 by , 12 years ago
Huh?
The standard reference seems to imply that
#include <algorithm> int main() { using std::swap; using std::swap; }
is legal iff
int main() { void swap(int&, int&); void swap(int&, int&); }
is legal. I would find it very weird if the latter is illegal.
comment:6 by , 12 years ago
Oops, thanks Steven! I was convinced that the latter was ill-formed, but I've reviewed the standard again and you are correct. Clang now implements the right semantics, so we should close out this patch as being wrong. Sorry about that!
comment:7 by , 12 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
Simple patch to libs/multi_index/test/test_modifiers.cpp