[llvm-bugs] [Bug 39628] New: Compound assignment to bool wrong in constexpr context

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Nov 11 09:29:06 PST 2018


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

            Bug ID: 39628
           Summary: Compound assignment to bool wrong in constexpr context
           Product: clang
           Version: 7.0
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: elmar.braun at web.de
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

Sample code (also at https://godbolt.org/z/E6BWs4):

constexpr bool f(bool b) {
    b = b | 2;
    return b;
}
constexpr bool g(bool b) {
    b |= 2;
    return b;
}
static_assert(f(true));
static_assert(f(false));
static_assert(g(true));
static_assert(g(false)); // fails unexpectedly

At runtime g(false) evaluates to true as expected.

-- 
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/20181111/e66db21f/attachment-0001.html>


More information about the llvm-bugs mailing list