[LLVMdev] Seeing a crash with ConstantFP::get
Dale Johannesen
dalej at apple.com
Fri Sep 7 10:05:45 PDT 2007
On Sep 7, 2007, at 8:47 AM, Chuck Rose III wrote:
> Hola Dale,
>
> Bumping it up to 3 bits makes everything work hunky dory on the PC
> side
> of my project. Would you like me to commit that?
>
> Also, after speaking with some VStudio folks, it looks like that issue
> will likely remain for VS2k8 as well.
I'd prefer to coerce VStudio into standard-conformant behavior, via
either flag or bug report.
But it sounds like you've tried. If that won't work, the 3-bit
workaround is OK with me
(but this is Neil's code originally). Please include a comment
explaining why you're
doing this.
> Another trick that was suggested to me was to try something along
> these
> lines:
>
> Enum E : unsigned int { A, B, C, D };
>
> ...
>
> Class ... {
>
> E e : 2;
>
> Unsigned int pad : 30;
>
> };
>
> Presumably you could reduce the pad size by switching it to an
> unsigned
> char. If you had 8 bits total worth of enums, presumably they
> could all
> fit into one.
>
> I didn't try that one out since your suggestion was simpler and
> worked.
> :-)
This sort of thing tends to break when somebody adds more fields.
While I don't
think that's likely in APFloat, I consider the 3-bit workaround better.
Thanks for analyzing this.
> Chuck.
>
> -----Original Message-----
> From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu]
> On Behalf Of Neil Booth
> Sent: Thursday, September 06, 2007 8:18 AM
> To: LLVM Developers Mailing List
> Subject: Re: [LLVMdev] Seeing a crash with ConstantFP::get
>
> Dale Johannesen wrote:-
>
>> You might argue with that one if you didn't feel like changing your
>> compiler, but 9 .6p4 is quite explicit:
>>
>> ... If the value of an enumerator is stored into a bitfield
>> of the same enumeration type and the number of bits in the bitfield
>> is large enough to hold all the values of that enumeration type, the
>> original enumerator value and the value of the bitfield
>> shall compare equal. [Example:
>> enum BOOL { f=0, t=1 };
>> struct A {
>> BOOL b:1;
>> };
>> A a;
>> void f() {
>> a.b = t;
>> if (a.b == t) // shall yield true
>> { /* ... */ }
>> }
>> ?end example]
>>
>> Looks just like your code.
>
> Good job finding that, thanks. :)
>
>>> It would be pretty sad indeed if
>>> assigning an enum of that type to the bitfield didn't then compare
>>> equal to itself :)
>>
>> I agree. So did the committee.
>
> One they got right then :)
>
> Neil.
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
More information about the llvm-dev
mailing list