<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 - __gcc_qadd produces spurious infinity"
   href="https://bugs.llvm.org/show_bug.cgi?id=49131">49131</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>__gcc_qadd produces spurious infinity
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>compiler-rt
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>11.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Other
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>compiler-rt
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>bbaren@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=24511" name="attach_24511" title="minimal example">attachment 24511</a> <a href="attachment.cgi?id=24511&action=edit" title="minimal example">[details]</a></span>
minimal example

__gcc_qadd, which adds two double-double long doubles on POWER, can incorrectly
return infinity instead of a finite result:

        $ cat ldbl.c
        extern int printf(const char* restrict, ...);
        int main() {
                long double a = -0x1.1e282e024debdb875f47f6c85p+1021L;
                printf("%Le\n", a + 0x1.fffffffffffff7ffffffffffff8p+1023L);
        }
        $ clang -Wall -Wextra -O0 -rtlib=compiler-rt -o ldbl ldbl.c
        $ ./ldbl
        inf

The two operands in this case are approximately -2.5e+307 and 1.8e+308; each
has a valid and finite double-double representation, and adding them should
produce another finite one. (In this case, the correct answer is about
1.5+308.)

I originally discovered this using Debian’s clang 11.0.1-2, but it’s also
present in non-Debian builds.

GCC produces the correct answer for this computation, though only when
optimizations are enabled (see
<a href="https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99048">https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99048</a>).</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>