<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 --- - LTO treats ObjC @selector's as compile time constants, which they are not"
href="http://llvm.org/bugs/show_bug.cgi?id=21490">21490</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>LTO treats ObjC @selector's as compile time constants, which they are not
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</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>freik@fb.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>For static/global values initialized with @selector syntax, the link time
optimizer treats them as if they're compile-time constants. This is true for
OSX and iOS.
Compile this -O2 (or -O3) with & without -flto:
#include <stdio.h>
#import <Foundation/Foundation.h>
@interface MyInterface : NSObject
// This selector also exists on NSString, so it gets adjusted at load time
-(NSUInteger)length;
@end
static SEL MySel = @selector(length);
int main(int argc, const char * argv[]) {
if (@selector(length) != MySel) {
printf("LTO BUG!\n");
return -1;
}
return 0;
}
The workaround for this issue is to use sel_registerName("length") instead of
the @selector syntax, though this is much slower.</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>