<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 --- - clang produces bogus numbers with -ffast-math -mfma -O2"
   href="http://llvm.org/bugs/show_bug.cgi?id=18715">18715</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang produces bogus numbers with -ffast-math -mfma -O2
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>trunk
          </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>pdknsk@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>$ clang --version
Ubuntu clang version 3.5-1~exp1 (trunk) (based on LLVM 3.5)
Target: i386-pc-linux-gnu

Unfortunately I don't have a reduced case, but it takes less than a minute to
get and run the code.

$ wget <a href="http://llvm.org/img/LLVM-Logo-Derivative-5.png">http://llvm.org/img/LLVM-Logo-Derivative-5.png</a> -O file.png
$ git clone <a href="https://github.com/pornel/mediancut-posterizer">https://github.com/pornel/mediancut-posterizer</a>
$ cd mediancut-posterizer

Now add two lines to posterize.c as described below.
<a href="https://github.com/pornel/mediancut-posterizer/issues/4">https://github.com/pornel/mediancut-posterizer/issues/4</a>

Compile and run.

$ CC=clang make
$ ./posterize -d -Q 100 ../file.png file.png -v
MSE=6.392 (Q=79, 255 levels)

$ make clean
$ CC=clang CFLAGSADD=-mfma make
$ ./posterize -d -Q 100 ../file.png file.png -v
MSE=221.115 (Q=0, 255 levels)

The output is totally false (and so is the file).

The Makefile sets quite a few flags, but only those mentioned in the topic are
relevant. You can just set them as CFLAGS directly if you prefer.

Both GCC 4.8 and ICC 14.0 compile the file correctly with or without FMA.</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>