[llvm-bugs] [Bug 37058] New: 7.1 2.2 Example does not work properly after disabling -fmerge-all-constants
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Apr 9 09:15:17 PDT 2018
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: unassignedbugs at nondot.org
Reporter: ilia.taraban at intel.com
CC: llvm-bugs at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180409/dae6a7c6/attachment.html>
More information about the llvm-bugs
mailing list