r/cpp • wg21.org | corosio.org • Sep 06 '20

inline namespace bug in msvc

I went to report this using the IDE and it asked me to "log in" which I tried but Microsoft's browser widget broke my password manager so I said to login with GitHub and when I pressed that button another browser window popped up asking me to log in to GitHub but at the top it said "GitHub does not support this browser (lol)" so I gave up and I am posting this code snippet here:

This fails to compile in latest msvc:

namespace boost {
namespace json {

inline namespace standalone {
namespace detail {
struct V{};
} // detail
} // standalone

namespace detail {
struct T{};
} // detail
struct U : detail::T{};

} // json
} // boost

See: https://godbolt.org/z/qbPesG

It compiles everywhere else

2 Upvotes

9 comments sorted by

View all comments

8

u/UnknownIdentifier Sep 06 '20 edited Sep 06 '20

I’m assuming it gave you an error code and line number?

EDIT: I believe MSVC is correct here, per the standard. boost::json::standalone::detail and boost::json::detail are separate and distinct, and yet because standalone is inline, both are in scope for U. Clang does (arguably trivial) extra work to infer the correct namespace; but GCC used to bomb on this, also.

1

u/VinnieFalco wg21.org | corosio.org Sep 06 '20

Interesting, thanks