<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html;
      charset=ISO-8859-2">
  </head>
  <body>
    <p>Hi Marko,</p>
    <p>I can't speak about the SCIP side of things, but on C++ side of
      things I believe this may somehow violate the One Definition Rule
      (<a href="https://en.wikipedia.org/wiki/One_Definition_Rule">ODR</a>).
      Violation of ODR is undefined behavior and I would speculate this
      is why there is heap corruption.<br>
    </p>
    <p>Building on top of the previous replies, I would try using a
      tagged union (or since you have access to C++17 use the better <a
        href="https://en.cppreference.com/w/cpp/utility/variant">std::variant</a>).
      Then you can typedef (once only!)<br>
    </p>
    <p><font color="#ff0000"><tt>using SCIP_ConsData =
          std::variant<ConsData1, ConsData2, ConsData3>;</tt></font></p>
    <p>and at call sites use std::get<ConsDataX> if you know the
      underlying datatype is (or use .index() to query the tag) to cast
      it back to the underlying type.</p>
    <p>I am not confident this solution will work, but hopefully this
      gives you an idea of why this problem arises.</p>
    <p>Regards,<br>
    </p>
    <p> Jim</p>
    <div class="moz-cite-prefix">On 22/10/20 7:37 pm, Horváth Markó
      wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:64efb69c-dea5-2352-a9c6-048ecf77daa0@sztaki.hu">Dear
      All,
      <br>
      <br>
      I am working on a branch-and-price project using SCIP, but I got
      stuck on something. Actually, I reduced my problem to a "simple"
      C++ issue, but due to the design of SCIP maybe you have already
      run into this problem and know the solution.
      <br>
      <br>
      So, my problem is that I have three different user-defined
      constraints and thus three different user-defined constraint data,
      that is, three different structures in three different .cpp files
      with the same name: SCIP_ConsData. (Due to the design of SCIP, I
      must use this name for all structures). Everything was fine when I
      used only the first two constraints (it was also a luck, I guess),
      however, the third one ruined everything. The problem is that in
      runtime these structures are mixed up which causes a heap
      corruption.
      <br>
      <br>
      More precisely, I have three SCIP_ConsData structures in different
      .cpp files (say, one.cpp, two.cpp, three.cpp) and when I want to
      create a new instance of the corresponding SCIP_ConsData in file
      two.cpp, the structure in file one.cpp is going to be created.
      Later, it will cause a heap corruption.
      <br>
      <br>
      What should I do to fix this issue?
      <br>
      <br>
      I attach a very minimal working example for this phenomenon. I use
      Visual Studio 2019 under Windows 10 with C++17 Standard.
      <br>
      <br>
      Best Regards,
      <br>
      Marko
      <br>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
Scip mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Scip@zib.de">Scip@zib.de</a>
<a class="moz-txt-link-freetext" href="https://listserv.zib.de/mailman/listinfo/scip">https://listserv.zib.de/mailman/listinfo/scip</a>
</pre>
    </blockquote>
  </body>
</html>