[llvm-bugs] [Bug 43557] New: __builtin_constant_p returns 1 instead of 0 when there is a side effect

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Oct 4 01:51:16 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=43557

            Bug ID: 43557
           Summary: __builtin_constant_p returns 1 instead of 0 when there
                    is a side effect
           Product: new-bugs
           Version: 9.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: release blocker
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: vincent-llvm at vinc17.net
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org

If the value of __builtin_constant_p is constant, 1 is returned even when there
is a side effect. This is a regression in Clang 9.

Testcase:

#include <stdio.h>

int main (void)
{
  int c, i = 0;
  c = __builtin_constant_p ((i++, 0));
  printf ("%d %d\n", c, i);
  return 0;
}

which outputs "1 0" instead of "0 0" with:

clang version 9.0.0-1 (tags/RELEASE_900/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

(Debian package clang-9 1:9-1).

Note: This makes one test of GNU MPFR fail (tcmp_ui) and can affect code using
MPFR, when this user code is built with Clang 9.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20191004/f18cf512/attachment.html>


More information about the llvm-bugs mailing list