<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><span class="vcard"><a class="email" href="mailto:douglas_yung@playstation.sony.com" title="Douglas Yung <douglas_yung@playstation.sony.com>"> <span class="fn">Douglas Yung</span></a>
</span> changed
<a class="bz_bug_link
bz_status_REOPENED "
title="REOPENED - Test using strcmp fails after r339410"
href="https://bugs.llvm.org/show_bug.cgi?id=38657">bug 38657</a>
<br>
<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>What</th>
<th>Removed</th>
<th>Added</th>
</tr>
<tr>
<td style="text-align:right;">Status</td>
<td>RESOLVED
</td>
<td>REOPENED
</td>
</tr>
<tr>
<td style="text-align:right;">Resolution</td>
<td>INVALID
</td>
<td>---
</td>
</tr></table>
<p>
<div>
<b><a class="bz_bug_link
bz_status_REOPENED "
title="REOPENED - Test using strcmp fails after r339410"
href="https://bugs.llvm.org/show_bug.cgi?id=38657#c5">Comment # 5</a>
on <a class="bz_bug_link
bz_status_REOPENED "
title="REOPENED - Test using strcmp fails after r339410"
href="https://bugs.llvm.org/show_bug.cgi?id=38657">bug 38657</a>
from <span class="vcard"><a class="email" href="mailto:douglas_yung@playstation.sony.com" title="Douglas Yung <douglas_yung@playstation.sony.com>"> <span class="fn">Douglas Yung</span></a>
</span></b>
<pre>Sorry, when cutting down the test, I think I may have invalidated it. Here is
the original test case:
/* test.cpp */
#include <string.h>
#include <assert.h>
struct String {
char content[100];
String (const String& a) {
strcpy(content, a.content);
}
String (const char* a) {
strcpy(content, a);
}
operator const char* () const {
return content;
}
};
String operator+ (const String& a, const String& b) {
String res("Error!");
if (strcmp(a, "one") == 0 && strcmp(b, "one") == 0) {
res = String("two");
}
if (strcmp(a, "one") == 0 && strcmp(b, "two") == 0) {
res = String("three");
}
return res;
}
int main()
{
String res1 = String("one") + String("two");
assert(strcmp(res1, "three") == 0);
char const* str1 = String("one") + String("two");
assert(strcmp(str1, "three") == 0);
String res2 = String("one") + "one";
assert(strcmp(res2, "two") == 0);
char const* str2 = String("one") + "one";
assert(strcmp(str2, "two") == 0);
String res3 = "one" + String("two");
assert(strcmp(res3, "three") == 0);
char const* str3 = "one" + String("two");
assert(strcmp(str3, "three") == 0);
return 0;
}
On my machine with gcc 5.5 and -O2, the code does NOT fail, while with clang
r399410 it does.</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>