[spirit] VC10 ICE when defining a Karma/Qi rule in a 0x lambda

Hi list, I encountered a rather amusing/horrible compiler error today when trying to wrap my head around the new Spirit. Apparently, VC++10 experiences a fatal internal compiler error when defining a Karma or Qi rule inside a lambda expression, as shown in the attached source at the bottom of this mail (and in the bug report). I reported a spirit bug [1] and a kind soul on the #boost channel linked me a similar Microsoft Connect bug [2], which seems to have sadly been ignored. I've got no idea in what edge of Spirit to start investigating this, as there's deep magic going on inside it, and would appreciate advice on what might be at fault, and whether there are any knobs I can twiddle. Could it be related to the recent thread on incomplete decltypes and odd rvalue references that VC10 has? [1] https://svn.boost.org/trac/boost/ticket/4160 [2] http://connect.microsoft.com/VisualStudio/feedback/details/541534/internal-c... //---8<--- #include <boost/spirit/include/karma.hpp> int main() { []() { boost::spirit::karma::rule<char*> r; }; } //---8<--- -- Lars Viklund | zao@acc.umu.se

I encountered a rather amusing/horrible compiler error today when trying to wrap my head around the new Spirit.
Apparently, VC++10 experiences a fatal internal compiler error when defining a Karma or Qi rule inside a lambda expression, as shown in the attached source at the bottom of this mail (and in the bug report).
I reported a spirit bug [1] and a kind soul on the #boost channel linked me a similar Microsoft Connect bug [2], which seems to have sadly been ignored.
I've got no idea in what edge of Spirit to start investigating this, as there's deep magic going on inside it, and would appreciate advice on what might be at fault, and whether there are any knobs I can twiddle.
Could it be related to the recent thread on incomplete decltypes and odd rvalue references that VC10 has?
[1] https://svn.boost.org/trac/boost/ticket/4160 [2] http://connect.microsoft.com/VisualStudio/feedback/details/541534/intern al-compiler-error-in-lambda-expression#
//---8<--- #include <boost/spirit/include/karma.hpp>
int main() { []() { boost::spirit::karma::rule<char*> r; }; } //---8<---
The code you gave compiles just fine using g++ with --std=c++0x (I tried V4.3.4). So I'm really not sure what we could do about this. So this is not an issue related to Spirit in any way. VC10 has some basic support for C++0x lambdas, but it seems to be too buggy to be useful. I'd suggest to wait for an update, but wouldn't hold my breath. Regards Hartmut --------------- Meet me at BoostCon www.boostcon.com

On 28/04/10 14:21, Hartmut Kaiser wrote:
//---8<--- #include <boost/spirit/include/karma.hpp>
int main() { []() { boost::spirit::karma::rule<char*> r; }; } //---8<---
The code you gave compiles just fine using g++ with --std=c++0x (I tried V4.3.4).
Really? I didn't think g++ supported lambdas until 4.5. The above code doesn't compile here on 4.4.3. http://gcc.gnu.org/gcc-4.3/cxx0x_status.html http://gcc.gnu.org/gcc-4.4/cxx0x_status.html http://gcc.gnu.org/gcc-4.5/cxx0x_status.html John Bytheway

On 28/04/10 14:21, Hartmut Kaiser wrote:
//---8<--- #include <boost/spirit/include/karma.hpp>
int main() { []() { boost::spirit::karma::rule<char*> r; }; } //---8<---
The code you gave compiles just fine using g++ with --std=c++0x (I tried V4.3.4).
Really? I didn't think g++ supported lambdas until 4.5. The above code doesn't compile here on 4.4.3.
http://gcc.gnu.org/gcc-4.3/cxx0x_status.html http://gcc.gnu.org/gcc-4.4/cxx0x_status.html http://gcc.gnu.org/gcc-4.5/cxx0x_status.html
Sorry, got the wrong version number down. I tested with V4.5. Regards Hartmut --------------- Meet me at BoostCon www.boostcon.com

I report a similar bug just a few minutes before I read this... https://connect.microsoft.com/VisualStudio/feedback/details/555365/c-compile... After having looked at the source of boost::algorithm::to_lower_s, I believe it's the same issue.

The issue is with calling template functions with default parameters from lambdas (where the type of the default parameter has a user defined destructor). User workaround: Explicitly pass the a value of the argument equivilent to the default instead of using the default argument. Library maintainer workaround: A function with default arguments can be trivially converted to overloaded functions without default parameters.

[Joseph Gauterin]
I report a similar bug just a few minutes before I read this... https://connect.microsoft.com/VisualStudio/feedback/details/555365/c-compile... After having looked at the source of boost::algorithm::to_lower_s, I believe it's the same issue.
Thanks very much for the minimal test case! Our compiler devs will enjoy it much more than a 12 MB preprocessed file. One of our testers has confirmed that our recent lambda fixes don't fix this ICE. It's also triggering a compiler assertion, which will lead them to the problem (or at least one of the problems). Stephan T. Lavavej Visual C++ Libraries Developer

[Lars Viklund]
I reported a spirit bug [1] and a kind soul on the #boost channel linked me a similar Microsoft Connect bug [2], which seems to have sadly been ignored. [2] http://connect.microsoft.com/VisualStudio/feedback/details/541534/internal-c...
It wasn't ignored - one of our compiler front-end testers tried to reproduce it twice and was unable to. (Note that because the bug wasn't reactivated, we didn't see the last two comments. Since I don't actually know what happens when a Connect bug is reactivated, whenever I resolve Connect bugs about the Standard Library, I just provide my E-mail address.) I've reproduced this with VC10 RTM and I've filed internal bug number 895716. I can't promise that this will be fixed in C1XX, but ICEs-on-valid are considered very obnoxious. (By the way, even if we had been able to reproduce this originally, there would have been no way to fix a bug reported in 3/12/2010 in VC10 RTM.) [Hartmut Kaiser]
VC10 has some basic support for C++0x lambdas, but it seems to be too buggy to be useful. I'd suggest to wait for an update, but wouldn't hold my breath.
Actually, several lambda fixes were recently checked into one of our branches. I live in a different branch so I can't easily say whether those fixes apply to this ICE. One problem, on top of the fact that new features always have bugs, is that the original specification of lambdas was very unclear about a number of corner cases. This was fixed in the C++0x Working Paper, but not in time for us to implement it. VC10 implements what I refer to as "lambdas v1.0" while GCC 4.5.0 implements "lambdas v1.1". The difference is most apparent when it comes to nested lambdas and name lookup. Thanks, Stephan T. Lavavej Visual C++ Libraries Developer
participants (5)
-
Hartmut Kaiser
-
John Bytheway
-
Joseph Gauterin
-
Lars Viklund
-
Stephan T. Lavavej