Hi, I don't know enough C to know for certain if this is a programmer or compiler error: In a Objective-C source file I have: . static const char sessionEntriesKVO = ' '; . Later I use that variable as a ID by taking it's address like this: [feedManager addObserver:self forKeyPath:@"sessionEntriesCount" options:0 context:&sessionEntriesKVO]; and later . if (aContext == &sessionEntriesKVO) { . With GCC 4.2 everything works as expected but with LLVM-GCC it seems that the optimizer does something strange to the sessionEntriesKVO variable (I get strange "unrecognized selector sent to instance..." errors at runtime that has nothing to do with the sessionEntriesKVO). Removing the const keyword (or compiling with -O0) fixes the problem. --- Tatu Vaajalahti Tampere, Finland
On Oct 14, 2008, at 12:52 PM, Tatu Vaajalahti wrote:> > Hi, > > I don't know enough C to know for certain if this is a programmer or > compiler error:Hi Tatu, With this information it is impossible to tell if it is your fault or llvm's fault. Please file a bug with a testcase that demonstrates the problem, thanks! -Chris> > > In a Objective-C source file I have: > > . > static const char sessionEntriesKVO = ' '; > . > > Later I use that variable as a ID by taking it's address like this: > > [feedManager addObserver:self forKeyPath:@"sessionEntriesCount" > options:0 context:&sessionEntriesKVO]; > > and later > > . > if (aContext == &sessionEntriesKVO) { > . > > With GCC 4.2 everything works as expected but with LLVM-GCC it seems > that the optimizer does something strange to the sessionEntriesKVO > variable (I get strange "unrecognized selector sent to instance..." > errors at runtime that has nothing to do with the sessionEntriesKVO). > > Removing the const keyword (or compiling with -O0) fixes the problem. > > --- > Tatu Vaajalahti > Tampere, Finland > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
On 15.10.2008, at 3.42, Chris Lattner wrote:> > On Oct 14, 2008, at 12:52 PM, Tatu Vaajalahti wrote: > >> >> Hi, >> >> I don't know enough C to know for certain if this is a programmer or >> compiler error: > > Hi Tatu, > > With this information it is impossible to tell if it is your fault or > llvm's fault. Please file a bug with a testcase that demonstrates the > problem, thanks! > > -ChrisHi Chris, With this program llvm-gcc -O2 optimizes test2 away even though it's address is taken in program (gcc-4.2 does not, neither does llvm-gcc with -O or -O0): #include <stdio.h> static const char test1 = 'x'; static const char test2 = 'x'; int main(int argc, char **argv) { printf("%p\n", &test1); printf("%p\n", &test2); return 0; } --- Tatu Vaajalahti Tampere, Finland