<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi,<div><br></div><div>I don't know enough C to know for certain if this is a programmer or compiler error:</div><div><br></div><div>In a Objective-C source file I have:</div><div><br></div><div>.</div><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Courier; "><span style="color: #106e33">static</span> const <span style="color: #106e33">char</span> sessionEntriesKVO = <span style="color: #1c00cf">' '</span>;</div></div><div>.</div><div><br></div><div>Later I use that variable as a ID by taking it's address like this:</div><div><br></div><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Courier; color: rgb(0, 65, 184); "><span style="color: #000000">[</span><span style="color: #620f7e">feedManager</span><span style="color: #000000"> </span>addObserver<span style="color: #000000">:</span><span style="color: #106e33">self</span><span style="color: #000000"> </span>forKeyPath<span style="color: #000000">:</span><span style="color: #b60000">@"sessionEntriesCount"</span><span style="color: #000000"> </span>options<span style="color: #000000">:</span><span style="color: #be4f00">0</span><span style="color: #000000"> </span>context<span style="color: #000000">:&</span><span style="color: #620f7e">sessionEntriesKVO</span><span style="color: #000000">];</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Courier; color: rgb(0, 65, 184); "><font class="Apple-style-span" color="#000000"><br></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Courier; color: rgb(0, 65, 184); "><font class="Apple-style-span" color="#000000">and later</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Courier; color: rgb(0, 65, 184); "><font class="Apple-style-span" color="#000000"><br></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Courier; color: rgb(0, 65, 184); "><font class="Apple-style-span" color="#000000">.</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Courier; color: rgb(0, 65, 184); "><font class="Apple-style-span" color="#000000"><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Courier; "><span style="color: #106e33">if</span> (aContext == &<span style="color: #620f7e">sessionEntriesKVO</span>) {</div></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Courier; color: rgb(0, 65, 184); "><font class="Apple-style-span" color="#000000">.</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Courier; color: rgb(0, 65, 184); "><font class="Apple-style-span" color="#000000"><br></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Courier; color: rgb(0, 65, 184); "><font class="Apple-style-span" color="#000000">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).</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Courier; color: rgb(0, 65, 184); "><font class="Apple-style-span" color="#000000"><br></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Courier; color: rgb(0, 65, 184); "><font class="Apple-style-span" color="#000000">Removing the const keyword (or compiling with -O0) fixes the problem.</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Courier; color: rgb(0, 65, 184); "><br></div></div><div><div> <span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div><div>---</div><div>Tatu Vaajalahti</div><div>Tampere, Finland</div><div><br></div></div><br></div></div></span><br class="Apple-interchange-newline"></div></span><br class="Apple-interchange-newline"></div></span><br class="Apple-interchange-newline"> </div><br></div></body></html>