<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Bullet3 sample code crashes when compiled clang-cl -m32 /O2. Does not crash with /O0"
   href="https://bugs.llvm.org/show_bug.cgi?id=41737">41737</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Bullet3 sample code crashes when compiled clang-cl -m32 /O2.  Does not crash with /O0
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>7.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>-New Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>merlynop@microsoft.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Note: affects -m32.  No repo if change to -m64.

Prereqs:
- Visual Studio 2019 with C++ Desktop Workload
(<a href="https://visualstudio.microsoft.com/vs/">https://visualstudio.microsoft.com/vs/</a>)
- Git
- Install LLVM 7.0.1 .msi (doesn't compile with Clang 8 or higher).

Open "x86 Native Tools Command Prompt for VS 2019"

git clone <a href="https://github.com/merlynoppenheim/bullet3.git">https://github.com/merlynoppenheim/bullet3.git</a> -b merlynop-testing

cd ..
md bullet3-build
cd bullet3-build

Set VSSKU=Community
set CXXFLAGS=-m32
set CFLAGS=-m32
Set CMAKEPATH=C:\PROGRAM FILES (X86)\MICROSOFT VISUAL
STUDIO\2019\%VSSKU%\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe
set NINJAPATH=C:\PROGRAM FILES (X86)\MICROSOFT VISUAL
STUDIO\2019\%VSSKU%\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\Ninja\ninja.exe
Set CLANGPATH=C:/PROGRAM FILES (X86)/Llvm/bin/clang-cl.exe
Set SOURCEPATH=..\bullet3

"%CMAKEPATH%" -G Ninja -DCMAKE_CXX_COMPILER="%CLANGPATH%"
-DCMAKE_C_COMPILER="%CLANGPATH%"  -DCMAKE_BUILD_TYPE="RelWithDebInfo" 
"%SOURCEPATH%" -DCMAKE_MAKE_PROGRAM="%NINJAPATH%"

"%CMAKEPATH%" --build . -- -v

Run: examples\ExampleBrowser\App_ExampleBrowser.exe

Unexpected result: App_ExampleBrowser.exe crashes

Example clang-cl args: -TP /GR- /Gy /GF -m32  /DWIN32  /W3  /EHsc /arch:SSE2
/fp:fast /wd4244 /wd4267 /MT /Zi /O2 /Ob1 /DNDEBUG 

The exception occurs in b3GraphicsInstance constructor, I suspect when calling
b3MakeVector3, an inline method.

<span class="quote">>        App_ExampleBrowser.exe!b3GraphicsInstance::b3GraphicsInstance() Line 179        C++</span >
        App_ExampleBrowser.exe!GLInstancingRenderer::registerShape(const float
* vertices, int numvertices, const int * indices, int numIndices, int
primitiveType, int textureId) Line 1100    C++
        App_ExampleBrowser.exe!OpenGLGuiHelper::registerGraphicsShape(const
float * vertices, int numvertices, const int * indices, int numIndices, int
primitiveType, int textureId) Line 337  C++
       
App_ExampleBrowser.exe!OpenGLGuiHelper::createCollisionShapeGraphicsObject(btCollisionShape
* collisionShape) Line 942  C++
       
App_ExampleBrowser.exe!OpenGLGuiHelper::autogenerateGraphicsObjects(btDiscreteDynamicsWorld
* rbWorld) Line 1351        C++
        App_ExampleBrowser.exe!BasicExample::initPhysics() Line 114     C++
        App_ExampleBrowser.exe!selectDemo(int demoIndex) Line 455       C++
        App_ExampleBrowser.exe!OpenGLExampleBrowser::init(int argc, char * *
argv) Line 1115    C++
        App_ExampleBrowser.exe!main(int argc, char * * argv) Line 75    C++
        App_ExampleBrowser.exe!_initterm(void(*)() * first, void(*)() * last)
Line 16   C++

Sorry for the mega-repro!</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>