<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 --- - Instructions for implicit copy constructor not generated on ARM64"
href="http://llvm.org/bugs/show_bug.cgi?id=22843">22843</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Instructions for implicit copy constructor not generated on ARM64
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</td>
</tr>
<tr>
<th>Version</th>
<td>3.5
</td>
</tr>
<tr>
<th>Hardware</th>
<td>Macintosh
</td>
</tr>
<tr>
<th>OS</th>
<td>MacOS X
</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>new bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>aburnson@museami.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=14008" name="attach_14008" title="Reproduce case">attachment 14008</a> <a href="attachment.cgi?id=14008&action=edit" title="Reproduce case">[details]</a></span>
Reproduce case
In the below example, a color is defined through a base class RGB and a
subclass RGBA, which adds the A component. Both have constructors that
initialize their fields to 0.f. Then in the BuggySet function, an RGBA object
is passed by value (with implicit copy constructor) and then assigned to a
global color. The example sends a color with values of all 1.f into BuggySet.
However, when I build and run this on an iPhone 5s (arm64) in Xcode 6.1.1
(based on LLVM 3.5), I get the following output:
//BEFORE: 0.000000 0.000000 0.000000 0.000000
//AFTER: 131671817916329306678238380032.000000 0.000000 0.000000 1.000000
I have tried this in both Debug and Release builds (with and without
optimization enabled) and get the same error. Looking at the disassembled
output, it looks like the implicit copy constructor for the pass-by-value into
BuggySet is not called for the base class:
;;;Right before call to BuggySet
0x1000d2de8: ldur w8, [fp, #-24]
0x1000d2dec: str w8, [sp, #40]
0x1000d2df0: ldur w8, [fp, #-20]
0x1000d2df4: str w8, [sp, #44]
0x1000d2df8: ldur w8, [fp, #-16]
0x1000d2dfc: str w8, [sp, #48]
0x1000d2e00: ldur w8, [fp, #-12]
0x1000d2e04: str w8, [sp, #52]
0x1000d2e08: ldr s0, [sp, #52]
0x1000d2e0c: bl 0x1000d2d3c ; BuggySet(RGBA) at main.mm:34
BadBug`BuggySet(RGBA) at main.mm:34:
;;;Points sp to beginning of uninitialized RGBA object ('NewColor' param)
0x1000d2d3c: sub sp, sp, #16
0x1000d2d40: adrp x8, 2
0x1000d2d44: add x8, x8, #3336
;;;The .A component is copied here but sp, sp #4, sp #8, i.e. RGB are missing
0x1000d2d48: str s0, [sp, #12]
0x1000d2d4c: ldr w9, [sp]
0x1000d2d50: str w9, [x8]
0x1000d2d54: ldr w9, [sp, #4]
0x1000d2d58: str w9, [x8, #4]
0x1000d2d5c: ldr w9, [sp, #8]
0x1000d2d60: str w9, [x8, #8]
0x1000d2d64: ldr w9, [sp, #12]
0x1000d2d68: str w9, [x8, #12]
0x1000d2d6c: add sp, sp, #16
0x1000d2d70: ret
Code sample below (also attached):
//-----------------------------------
#import <Foundation/Foundation.h>
class RGB
{
public:
float R;
float G;
float B;
RGB()
{
R = 0.f;
G = 0.f;
B = 0.f;
};
};
class RGBA : public RGB
{
public:
float A;
RGBA()
{
A = 0.f;
}
};
RGBA Color;
void BuggySet(RGBA NewColor)
{
Color = NewColor;
}
int main()
{
RGBA TestColor;
TestColor.R = 1.f;
TestColor.G = 1.f;
TestColor.B = 1.f;
TestColor.A = 1.f;
NSLog(@"BEFORE: %f %f %f %f", Color.R, Color.G, Color.B, Color.A);
BuggySet(TestColor);
NSLog(@"AFTER: %f %f %f %f", Color.R, Color.G, Color.B, Color.A);
return 0;
}
//-----------------------------------</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>