[LLVMdev] LLVM 2.4 problem? (resend)

Chris Lattner clattner at apple.com
Wed Oct 15 08:28:14 PDT 2008


On Oct 15, 2008, at 6:58 AM, Tatu Vaajalahti wrote:
>> Yes, but why do you think they should get a different address?  I can
>> understand that it is surprising that they do, but determining  
>> whether
>> this is legal or not requires reading the language standard.
>> Hopefully
>> a language lawyer can chime in and say whether this transform is  
>> valid
>> or not.
>
>
> I agree the whole construction is a litle bit strange (stupid even).
> It is however common way to specify context identity in one Objective-
> C pattern (although I don't think anyone actually uses initialized
> const variables, I was just playing with them to see how compilers put
> stuff in segments).
>
> I do think however that it's bit dangerous to combine static constants
> across compilation units.

GCC does the same things with strings in some cases.  You shouldn't  
depend on this behavior if you want portable code.  If you avoid  
marking the global variable const, you should have better luck.

-Chris



More information about the llvm-dev mailing list