<html>
    <head>
      <base href="http://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 when compiling function template with deep recursion"
   href="http://llvm.org/bugs/show_bug.cgi?id=15560">15560</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Segmentation fault when compiling function template with deep recursion
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>3.2
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Macintosh
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>MacOS X
          </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>C++
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>Juan.Arrieta@jpl.nasa.gov
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>This program uses a template-based definition of some common polynomials, and
them attempts to evaluate them at large orders. While it may seem artificial to
use a 200th-order polynomial, it is quite common in cases like geopotential
evaluation using spherical harmonics.

There are other means to evaluate the geopotential function, but this program
aims to test whether the compiler optimizations made available by means of
templates can expedite the computations and reduce roundoff errors.

This program uses the ``constexpr`` specifier (which marks a function as a
compile-time target). For this reason, only a compiler with C++11 support will
be able to compile.

The program runs extremely slowly when compiled with g++ with N=100. It runs
great when compiled with clang++ up to N~170. Compilation crashes in clang++ at
N=192. The last successful compilation looks as follows:

       clang++ polynomials.cpp -std=c++11 -O3 -DORDER=191   

Attempting the next compilation:

       clang++ polynomials.cpp -std=c++11 -O3 -DORDER=192

yields the following result:

clang: error: unable to execute command: Segmentation fault: 11
clang: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.2 (tags/RELEASE_32/final)
Target: x86_64-apple-darwin11.4.2
Thread model: posix
clang: note: diagnostic msg: PLEASE submit a bug report to
<a href="http://llvm.org/bugs/">http://llvm.org/bugs/</a> and include the crash backtrace, preprocessed source, and
associated run script.
clang: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg:
/var/folders/zz/zyxvpxvq6csfxvn_n0001dkm000bcn/T/polynomials-zXGdTS.cpp
clang: note: diagnostic msg:
/var/folders/zz/zyxvpxvq6csfxvn_n0001dkm000bcn/T/polynomials-zXGdTS.sh
clang: note: diagnostic msg: 

********************


clang++ version information:
clang version 3.2 (tags/RELEASE_32/final)
Target: x86_64-apple-darwin11.4.2
Thread model: posix

g++ version information:
Using built-in specs.
COLLECT_GCC=/usr/local/bin/g++
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-apple-darwin11.4.2/4.7.2/lto-wrapper
Target: x86_64-apple-darwin11.4.2
Configured with: ./configure
Thread model: posix
gcc version 4.7.2 (GCC)


System information:
OS X 10.7.4
Processor: 2.7 GHz Intel Core i7
Memory: 16GB 1600 MHz DDR3</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>