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

            Bug ID: 37058
           Summary: 7.1 2.2 Example does not work properly after disabling
                    -fmerge-all-constants
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedb...@nondot.org
          Reporter: ilia.tara...@intel.com
                CC: llvm-bugs@lists.llvm.org

This test starts failing after disabling -fmerge-all-constants:

================= nice.cpp ============

const char * goo (const char * s1, const char * s2)
{
    const char * p;
    if (* s2 == '\0') 
        return 0;
    p = 0;
    return 0;
}
void foo (const char * s)
{
    const char * p = goo(0, "S");
    int i;
}
struct S { int n; };
auto f ()
{
    S x = { 1 };
    constexpr S y = { 2 };
    return [&](bool b) { return (b ? y : x).n;
    };
}
auto g = f();
int main (int argc, char * argv [])
{
    foo(0);
    int n = g(true);  // OK, according to 7.1 2.2
    return 2 - n;   
}


=======================================

>>> clang -v
clang version 7.0.0 (trunk 329586)
Target: x86_64-unknown-linux-gnu
Thread model: posix
...

>>> clang++ -o nice.exe nice.cpp
>>> nice.exe
2
>>> clang++ -o nice.exe nice.cpp -fmerge-all-constants
>>> nice.exe
0

 So after disabling this option current test (which is similar to Example from
7.1 2.2) giving wrong result. Now x and y behave similar.
>>> @_ZZ3maxvE1a = private unnamed_addr constant %struct.A { i32 1 }, align 4
>>> @_ZZ3maxvE1b = private unnamed_addr constant %struct.A { i32 2 }, align 4

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to