Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>It looks like a compiler/linker bug: no C++ code should ever cause segfaults in the compiler/linker.</p> <p>By the way, how do you get this code to compile? How is <code>pointer</code> declared?</p> <pre><code>Class1Tuple tup("str", pointer); ClassTupleItem(tup); // works fine since I used Class1Tuple Class6Tuple tup2("str", pointer); ClassTupleItem(tup2); // causes a segfault. </code></pre> <p>If the classes are declared like this, for <code>Class1Tuple</code>, <code>pointer</code> should be a <code>shared_ptr&lt;Class1&gt;</code>, and for <code>Class6Tuple</code> it should be of a different type, <code>shared_ptr&lt;Class6&gt;</code>.</p> <pre><code>struct Class1 { typedef boost::shared_ptr&lt;Class1&gt; Ptr; /* ... */ }; /* ... */ struct Class6 { typedef boost::shared_ptr&lt;Class6&gt; Ptr; /* ... */ }; </code></pre> <p><strong>Edit:</strong> The following code compiles correctly with g++ 3.3.6. I am not able to test it on gcc 3.3.3 and SUSE Linux at the moment. Please try to compile this and see if the linker still gives a segfault.</p> <pre><code>#include &lt;boost/shared_ptr.hpp&gt; #include &lt;boost/tuple/tuple.hpp&gt; #include &lt;boost/variant.hpp&gt; #include &lt;string&gt; struct Class1 { typedef boost::shared_ptr&lt;Class1&gt; Ptr; /* .... */ }; struct Class2 { typedef boost::shared_ptr&lt;Class2&gt; Ptr; /* .... */ }; struct Class3 { typedef boost::shared_ptr&lt;Class3&gt; Ptr; /* .... */ }; struct Class4 { typedef boost::shared_ptr&lt;Class4&gt; Ptr; /* .... */ }; struct Class5 { typedef boost::shared_ptr&lt;Class5&gt; Ptr; /* .... */ }; struct Class6 { typedef boost::shared_ptr&lt;Class6&gt; Ptr; /* .... */ }; struct Class7 { typedef boost::shared_ptr&lt;Class7&gt; Ptr; /* .... */ }; typedef boost::tuple&lt;std::string, Class1::Ptr&gt; Class1Tuple; typedef boost::tuple&lt;std::string, Class2::Ptr&gt; Class2Tuple; typedef boost::tuple&lt;std::string, Class3::Ptr&gt; Class3Tuple; typedef boost::tuple&lt;std::string, Class4::Ptr&gt; Class4Tuple; typedef boost::tuple&lt;std::string, Class5::Ptr&gt; Class5Tuple; typedef boost::tuple&lt;std::string, Class6::Ptr&gt; Class6Tuple; typedef boost::tuple&lt;std::string, Class7::Ptr&gt; Class7Tuple; typedef boost::variant&lt; Class1Tuple, Class2Tuple, Class3Tuple, Class4Tuple, Class5Tuple, Class6Tuple, Class7Tuple &gt; ClassTupleItem; int main() { Class1::Ptr pointer; Class1Tuple tup("str", pointer); (ClassTupleItem(tup)); // Temporary object ClassTupleItem item(tup); Class6::Ptr pointer2; Class6Tuple tup2("str", pointer2); (ClassTupleItem(tup2)); // Temporary object ClassTupleItem item2(tup2); } </code></pre>
 

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