<html>
<head>
<base href="http://llvm.org/bugs/" />
</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 --- - Redundant zero-initialisation of automatic variables of user-defined type in member methods of a class template"
href="http://llvm.org/bugs/show_bug.cgi?id=20256">20256</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Redundant zero-initialisation of automatic variables of user-defined type in member methods of a class template
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>3.4
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>LLVM Codegen
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>jhart.public@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=12756" name="attach_12756" title="output of 'clang -flto -S -o - test.cpp'">attachment 12756</a> <a href="attachment.cgi?id=12756&action=edit" title="output of 'clang -flto -S -o - test.cpp'">[details]</a></span>
output of 'clang -flto -S -o - test.cpp'
In the following code snippet, a call to A::method() produces different
compiler output compared to a call to B<int>::method().
struct data { int i; };
struct A {
void method() {
data d;
d.i = 1;
}
};
template <typename T>
struct B {
void method() {
data d;
d.i = 1;
}
};
void test() {
A a;
B<int> b;
a.method();
b.method();
}
Expected: identical output from both methods.
The generated code differs as follows:
In A::method(), the non-template case, d.i is assigned the value of 1 as
expected. In B<int>::method(), the template case, d is first zero-initialised
before assigning d.i = 1.
Note the redundant zero-initialisation occurs only in the template case, and
only for user-defined types. Built-in types do not exhibit the same problem.</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>