[typeof] Weird VC++ compiler bug
I discovered a strange VC++ bug using Boost.typeof. I am not posting this to rag VC++ but wondering if there is some known workaround in Boost or in Boost.config. #include <boost/typeof/typeof.hpp> template <class T> struct dereference { typedef BOOST_TYPEOF_TPL(*T()) type; }; int main() { } Compiling this with VC++12 gives: test_vc_type_of_indirection.cpp(6) : error C2100: illegal indirection test_vc_type_of_indirection.cpp(7) : see reference to class template instantiation 'dereference<T>' being compiled Notice that I am not even instantiating 'dereference'. But if I write: #include <boost/typeof/typeof.hpp> template <class T> struct dereference { void afunction() { typedef BOOST_TYPEOF_TPL(*T()) type; } }; int main() { } all is well, for all the good it does me. BOOST_TYPEOF_TPL(*T()) expands to: typename boost::type_of::msvc_typeid_wrapper<sizeof(*boost::type_of::encode_start(*T()))>::type and if I substitute this directly the same results occur. I can report this to the VC++ bug tracker but wanted to see if this is a known problem with VC++ in Boost, some weird error for which maybe Boost has some workaround syntax.
AMDG On 05/22/2015 08:02 AM, Edward Diener wrote:
I discovered a strange VC++ bug using Boost.typeof. I am not posting this to rag VC++ but wondering if there is some known workaround in Boost or in Boost.config.
The workaround for most weird Boost.Typeof errors is BOOST_TYPEOF_NESTED_TYPEDEF_TPL. In Christ, Steven Watanabe
On 5/22/2015 11:24 AM, Steven Watanabe wrote:
AMDG
On 05/22/2015 08:02 AM, Edward Diener wrote:
I discovered a strange VC++ bug using Boost.typeof. I am not posting this to rag VC++ but wondering if there is some known workaround in Boost or in Boost.config.
The workaround for most weird Boost.Typeof errors is BOOST_TYPEOF_NESTED_TYPEDEF_TPL.
Thanks ! I saw that macro and saw the mention in the doc of "deconfusing several compilers (notably VC7.1 and VC8.0) on the way", and could not get it into my head that this could still be a problem with VC12. Of course I should have tried it. Oh Microsoft ! What's a little bug that you refuse to fix for at least a decade and counting.
On May 22, 2015 2:57:26 PM EDT, Edward Diener <eldiener@tropicsoft.com> wrote:
AMDG
On 05/22/2015 08:02 AM, Edward Diener wrote:
I discovered a strange VC++ bug using Boost.typeof. I am not
On 5/22/2015 11:24 AM, Steven Watanabe wrote: posting
this to rag VC++ but wondering if there is some known workaround in Boost or in Boost.config.
The workaround for most weird Boost.Typeof errors is BOOST_TYPEOF_NESTED_TYPEDEF_TPL.
Thanks !
I saw that macro and saw the mention in the doc of "deconfusing several compilers (notably VC7.1 and VC8.0) on the way", and could not get it into my head that this could still be a problem with VC12. Of course I should have tried it.
Oh Microsoft ! What's a little bug that you refuse to fix for at least a decade and counting.
Isn't the problem the lack of two-phase lookup in that compiler? ___ Rob (Sent from my portable computation engine)
On 5/23/2015 8:12 AM, Rob Stewart wrote:
On May 22, 2015 2:57:26 PM EDT, Edward Diener <eldiener@tropicsoft.com> wrote:
AMDG
On 05/22/2015 08:02 AM, Edward Diener wrote:
I discovered a strange VC++ bug using Boost.typeof. I am not
On 5/22/2015 11:24 AM, Steven Watanabe wrote: posting
this to rag VC++ but wondering if there is some known workaround in Boost or in Boost.config.
The workaround for most weird Boost.Typeof errors is BOOST_TYPEOF_NESTED_TYPEDEF_TPL.
Thanks !
I saw that macro and saw the mention in the doc of "deconfusing several compilers (notably VC7.1 and VC8.0) on the way", and could not get it into my head that this could still be a problem with VC12. Of course I should have tried it.
Oh Microsoft ! What's a little bug that you refuse to fix for at least a decade and counting.
Isn't the problem the lack of two-phase lookup in that compiler?
Considering that in my example which fails the class template never gets instantiated it does not seem that the lack of two-phase lookup should cause such an error. But whatever... Microsoft has a well-known system in place by which they decide that known bugs should not be fixed if they don't think it is important enough to do so.
AMDG On 05/23/2015 07:45 AM, Edward Diener wrote:
On 5/23/2015 8:12 AM, Rob Stewart wrote:
On May 22, 2015 2:57:26 PM EDT, Edward Diener <eldiener@tropicsoft.com> wrote:
Oh Microsoft ! What's a little bug that you refuse to fix for at least a decade and counting.
Isn't the problem the lack of two-phase lookup in that compiler?
Considering that in my example which fails the class template never gets instantiated it does not seem that the lack of two-phase lookup should cause such an error. But whatever... Microsoft has a well-known system in place by which they decide that known bugs should not be fixed if they don't think it is important enough to do so.
You can't blame microsoft too much for this particular problem, since the "native" typeof implementation of msvc relies on a compiler bug. In Christ, Steven Watanabe
Steven Watanabe wrote:
On 05/23/2015 07:45 AM, Edward Diener wrote: ...
But whatever... Microsoft has a well-known system in place by which they decide that known bugs should not be fixed if they don't think it is important enough to do so.
A bit unfair, methinks. They do what everyone does - try to strike a balance between adding features, fixing bugs and not breaking too much code.
You can't blame microsoft too much for this particular problem, since the "native" typeof implementation of msvc relies on a compiler bug.
Why doesn't Typeof use decltype on VS 2013?
2015-05-23 18:33 GMT+02:00 Steven Watanabe <watanabesj@gmail.com>:
AMDG
On 05/23/2015 09:44 AM, Peter Dimov wrote:
Why doesn't Typeof use decltype on VS 2013?
Probably because Typeof hasn't had a maintainer since before decltype. It doesn't appear to use decltype for any compiler.
I don't think it can. The semantics of BOOST_TYPEOF is that of: auto x = expr; The semantics of decltype are quire different. For instance, auto and BOOST_TYPEOF and GCC's __typeof__ never deduce references -- always values. decltype on the other hand can deduce references. I guess BOOST_TYPEOF could be implemented with decltype(auto). Regards, &rzej
On Wed, May 27, 2015 at 4:53 PM, Andrzej Krzemienski <akrzemi1@gmail.com> wrote:
2015-05-23 18:33 GMT+02:00 Steven Watanabe <watanabesj@gmail.com>:
AMDG
On 05/23/2015 09:44 AM, Peter Dimov wrote:
Why doesn't Typeof use decltype on VS 2013?
Probably because Typeof hasn't had a maintainer since before decltype. It doesn't appear to use decltype for any compiler.
I don't think it can. The semantics of BOOST_TYPEOF is that of: auto x = expr;
The semantics of decltype are quire different. For instance, auto and BOOST_TYPEOF and GCC's __typeof__ never deduce references -- always values. decltype on the other hand can deduce references.
As long as BOOST_TYPEOF is less precise than decltype it can be emulated, can it not?
---------- Forwarded message ---------- From: Andrey Semashev <andrey.semashev@gmail.com> Date: 2015-05-27 16:06 GMT+02:00 Subject: Re: [boost] [typeof] Weird VC++ compiler bug To: "boost@lists.boost.org" <boost@lists.boost.org> On Wed, May 27, 2015 at 4:53 PM, Andrzej Krzemienski <akrzemi1@gmail.com> wrote:
2015-05-23 18:33 GMT+02:00 Steven Watanabe <watanabesj@gmail.com>:
AMDG
On 05/23/2015 09:44 AM, Peter Dimov wrote:
Why doesn't Typeof use decltype on VS 2013?
Probably because Typeof hasn't had a maintainer since before decltype. It doesn't appear to use decltype for any compiler.
I don't think it can. The semantics of BOOST_TYPEOF is that of: auto x = expr;
The semantics of decltype are quire different. For instance, auto and BOOST_TYPEOF and GCC's __typeof__ never deduce references -- always values. decltype on the other hand can deduce references.
As long as BOOST_TYPEOF is less precise than decltype it can be emulated, can it not? You're right it can. I think the following would work: typename std::decay<decltype(expr)>::type Regards, &rzej
Andrzej Krzemienski wrote:
2015-05-23 18:33 GMT+02:00 Steven Watanabe <watanabesj@gmail.com>:
AMDG
On 05/23/2015 09:44 AM, Peter Dimov wrote:
Why doesn't Typeof use decltype on VS 2013?
Probably because Typeof hasn't had a maintainer since before decltype. It doesn't appear to use decltype for any compiler.
I don't think it can. The semantics of BOOST_TYPEOF is that of: auto x = expr;
It's not a problem to pass the result of decltype through decay<> or to use template<class T> T f( T ); decltype(f(expr));
On 5/23/2015 11:44 AM, Peter Dimov wrote:
Steven Watanabe wrote:
But whatever... Microsoft has a well-known system in place by which
On 05/23/2015 07:45 AM, Edward Diener wrote: ... they > decide that known bugs should not be fixed if they don't think it is > important enough to do so.
A bit unfair, methinks. They do what everyone does - try to strike a balance between adding features, fixing bugs and not breaking too much code.
Not fixing a bug over 10 years time ? That's not striking a balance to me.
You can't blame microsoft too much for this particular problem, since the "native" typeof implementation of msvc relies on a compiler bug.
Why doesn't Typeof use decltype on VS 2013?
On 5/23/2015 11:04 AM, Steven Watanabe wrote:
AMDG
On 05/23/2015 07:45 AM, Edward Diener wrote:
On 5/23/2015 8:12 AM, Rob Stewart wrote:
On May 22, 2015 2:57:26 PM EDT, Edward Diener <eldiener@tropicsoft.com> wrote:
Oh Microsoft ! What's a little bug that you refuse to fix for at least a decade and counting.
Isn't the problem the lack of two-phase lookup in that compiler?
Considering that in my example which fails the class template never gets instantiated it does not seem that the lack of two-phase lookup should cause such an error. But whatever... Microsoft has a well-known system in place by which they decide that known bugs should not be fixed if they don't think it is important enough to do so.
You can't blame microsoft too much for this particular problem, since the "native" typeof implementation of msvc relies on a compiler bug.
Does it rely on the exact compiler bug my OP illustrates ? Even if it does it is hard to imagine that there would be no Boost.typeof for VC++, since there is an implementation for more conforming compilers.
participants (6)
-
Andrey Semashev
-
Andrzej Krzemienski
-
Edward Diener
-
Peter Dimov
-
Rob Stewart
-
Steven Watanabe