<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </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 --- - Segmentation fault in seemingly valid code" href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_bugs_show-5Fbug.cgi-3Fid-3D24207&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=pW5ZHt-dlNsFR7yTCF--K4otdGpPljyxb4moox_Ck28&s=pmvsjdktXN2kFIVLztBUrKGOdtCIyNa98D8e9rIWRB8&e=">24207</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Segmentation fault in seemingly valid code
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>3.6
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>Linux
          </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>chbaker0@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>A test program for the library GLM (<a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_g-2Dtruc_glm&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=pW5ZHt-dlNsFR7yTCF--K4otdGpPljyxb4moox_Ck28&s=a6rSatMO0pde_8mwzhU2J66dQjacTWdDuXvgHJBXRNU&e=">https://github.com/g-truc/glm</a>) is crashing
due to a segmentation fault when compiled with clang++ but not with g++. The
test is "gtx_fast_trigonometry" and can be seen here:
<a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_g-2Dtruc_glm_blob_master_test_gtx_gtx-5Ffast-5Ftrigonometry.cpp&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=pW5ZHt-dlNsFR7yTCF--K4otdGpPljyxb4moox_Ck28&s=Ga_kaDIJjyIdUOqj1-ife9WFrGW_P-0LaHuJXgb8Tiw&e=">https://github.com/g-truc/glm/blob/master/test/gtx/gtx_fast_trigonometry.cpp</a>

The test is compiled and linked with flags "-std=c++11 -g".

Valgrind gives this trace:

=25726== Invalid read of size 4
==25726==    at 0x407CAB: glm::tvec1<float, (glm::precision)0>
glm::operator*<float, (glm::precision)0>(glm::tvec1<float, (glm::precision)0>
const&, glm::tvec1<float, (glm::precision)0> const&) (type_vec1.inl:434)
==25726==    by 0x407BBA: glm::tvec1<float, (glm::precision)0>
taylorCos::taylorSeriesNewCos6<float, (glm::precision)0,
glm::tvec1>(glm::tvec1<float, (glm::precision)0> const&)
(gtx_fast_trigonometry.cpp:226)
==25726==    by 0x4079F0: glm::tvec1<float, (glm::precision)0>
taylorCos::fastCosNew<float, (glm::precision)0, glm::tvec1>(glm::tvec1<float,
(glm::precision)0> const&) (in
/home/collin/Development/Libraries/builds/glm/test/gtx/test-gtx_fast_trigonometry)
==25726==    by 0x40653E: taylorCos::test() (gtx_fast_trigonometry.cpp:450)
==25726==    by 0x4065CA: main (gtx_fast_trigonometry.cpp:464)
==25726==  Address 0xf7f0002d0 is not stack'd, malloc'd or (recently) free'd

GDB traps at the same point, and a backtrace gives this:

#0  0x0000000000407cab in glm::operator*<float, (glm::precision)0> (v1=...,
v2=...)
    at
/home/collin/Development/Libraries/sources/glm/glm/gtc/../detail/type_vec1.inl:434
#1  0x0000000000407bbb in taylorCos::taylorSeriesNewCos6<float,
(glm::precision)0, glm::tvec1> (x=...)
    at
/home/collin/Development/Libraries/sources/glm/test/gtx/gtx_fast_trigonometry.cpp:226
#2  0x00000000004079f1 in taylorCos::fastCosNew<float, (glm::precision)0,
glm::tvec1> (x=...)
    at
/home/collin/Development/Libraries/sources/glm/test/gtx/gtx_fast_trigonometry.cpp:251
#3  0x000000000040653f in taylorCos::test ()
    at
/home/collin/Development/Libraries/sources/glm/test/gtx/gtx_fast_trigonometry.cpp:450
#4  0x00000000004065cb in main () at
/home/collin/Development/Libraries/sources/glm/test/gtx/gtx_fast_trigonometry.cpp:464

At frame #2, `info args` in GDB prints "x = @0x7fff7fffe300: <error reading
variable>", and similar for #1 and #0.

When compiled with g++, the program is Valgrind-clean. I don't see any
undefined behavior in the relevant functions, but I could be wrong. I'm
concerned that there might be a code generation bug.</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>