Note that there are some explanatory texts on larger screens.

plurals
  1. POIntel C++ compiler can't handle deep templates?
    primarykey
    data
    text
    <p>I have a project in C++ using <a href="https://github.com/bjoern-andres/marray" rel="nofollow noreferrer">marray</a> library. For now it compiles and runs quite fine with MinGW g++ 4.7 and msvc2010 on Windows 7 x64 and also with g++ 4.7 on Linux Mint x64. I decided to give a try to Intel C++ compiler v. 12.1.4 for Linux. It was able to compile the code but when it tries to execute any line bothering expression templates (like c = a + b where all three terms are matrices) it breaks down with segmentation fault. This issue affects both debug and release versions of the app. </p> <p>I also tried to compile unit tests and tutorial code for marray library and again, Intel C++ compiles the code but fails to run it if it has any expression templates. Is Intel C++ really as bad with deep templates or am I missing something? Do I need to set any special compiler flags to make template expressions work? Or maybe it is just something wrong with the particular library I'm using, not the expression templates technique in general?</p> <p>I also tried to set the <em>-ftemplate-depth-<strong>n</em></strong> flag using a wide variety on <strong><em>n</em></strong> up to ridiculously large values of 10^10 and still had no luck in running neither my app nor marray unit tests/tutorial without the segmentation fault. </p> <p><strong>Upd.:</strong> Here is the gdb log for tutorial-marray from the mentioned library compiled with icpc in debug mode. </p> <pre><code>GNU gdb (Ubuntu/Linaro 7.3-0ubuntu2) 7.3-2011.08 Copyright (C) 2011 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later &lt;http://gnu.org/licenses/gpl.html&gt; This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-linux-gnu". For bug reporting instructions, please see: &lt;http://bugs.launchpad.net/gdb-linaro/&gt;... Reading symbols from /home/dmitry/SOFT/Development/marray_orig/tutorial-marray...done. (gdb) l 126 121 size_t shape[] = {3, 4, 2}; 122 marray::Marray&lt;int&gt; a(shape, shape + 3, 2); 123 marray::Marray&lt;int&gt; b(shape, shape + 3, 2); 124 marray::Marray&lt;int&gt; c; 125 126 ++a; 127 --a; 128 129 a += 2; 130 a -= 2; (gdb) break 126 Breakpoint 1 at 0x452de8: file /home/dmitry/SOFT/Development/marray_orig/marray/src/tutorial/tutorial.cxx, line 126. (gdb) run Starting program: /home/dmitry/SOFT/Development/marray_orig/tutorial-marray A(c,r,0) = 1 0 0 0 0 0 0 0 0 0 0 0 A(c,r,1) = 0 0 0 0 0 0 0 0 0 0 0 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 Breakpoint 1, main () at /home/dmitry/SOFT/Development/marray_orig/marray/src/tutorial/tutorial.cxx:126 126 ++a; (gdb) next 127 --a; (gdb) next 129 a += 2; (gdb) next 130 a -= 2; (gdb) next 131 a /= 2; (gdb) next 132 a *= 2; (gdb) next 134 c = a + b; (gdb) next Program received signal SIGSEGV, Segmentation fault. 0x0000000000420fcf in marray::ViewExpression&lt;marray::View&lt;int, false, std::allocator&lt;unsigned long&gt; &gt;, int&gt;::operator marray::View&lt;int, false, std::allocator&lt;unsigned long&gt; &gt; const&amp; (this=0x7fffffffcd88) at /home/dmitry/SOFT/Development/marray_orig/marray/include/marray/marray.hxx:5409 5409 { return static_cast&lt;const E&amp;&gt;(*this); } (gdb) </code></pre> <p>Looks like the problem doesn't originate from the expression template technique in general, array arithmetics with numbers works fine. The problem arises when I'm trying to add one array to another. </p> <p><strong>Upd. 2:</strong> Actually the whole thing looks quite like the problem mentioned <a href="https://stackoverflow.com/questions/9738975/crtp-compiler-dependent-issue-with-expression-template">here</a>. The solution should be in rewriting operator E&amp;() { return static_cast(*this); } into something like E&amp; get_ref() { return static_cast(*this); } and the same thing for const reference. And, of course, change the usage of these things within the code. Will try it as soon as I can and report the results. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload