<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - /GUARD:CF considers member function template parameters to be address taken when they are not, resulting in link errors"
href="https://bugs.llvm.org/show_bug.cgi?id=43858">43858</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>/GUARD:CF considers member function template parameters to be address taken when they are not, resulting in link errors
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Common Code Generator Code
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>rnk@google.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>I summarized this first here: <a href="https://crbug.com/1019970#c12">https://crbug.com/1019970#c12</a>
Related to issue 33143.
Consider this code:
$ cat t.cpp
struct Foo { void bar(); };
template <void (Foo::*FN)()> struct useNonTpParam {
static void donothing() {}
};
void addrTaken();
void (*gfp)();
int main() {
gfp = addrTaken;
useNonTpParam<&Foo::bar>::donothing();
}
$ clang -cc1 -triple i686-windows-msvc -fms-extensions t.cpp -gcodeview
-debug-info-kind=limited -S -o t.s -cfguard-no-checks && grep symidx t.s
.symidx "?addrTaken@@YAXXZ"
.symidx "?bar@Foo@@QAEXXZ"
Foo::bar is used as a non-type template parameter, but it is not actually
address taken. Debug info emission creates a constant bitcast of the function,
which remains around, causing Function::hasAddressTaken to return true for
Foo::bar later. This results in emitting .symidx for it.
Both linkers treat undefined symbols as strong references to Foo::bar, so this
can result in link errors. Even if the user "uses" Foo::bar, the behavior is
surprising, and the codegen depends on whether -g is enabled, which is bad.</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>