[LLVMdev] Virtual Studio hack in APFloat.h
Reid Kleckner
rnk at google.com
Tue Mar 25 13:46:05 PDT 2014
Yes, this is the way to go. Without an explicit integer type, MSVC always
picks "int" to represent the enum, which is signed. The only way to avoid
this is to use C++11 strong enums, which we can do unconditionally now.
We can also apply this to GlobalValue, I believe.
On Thu, Mar 20, 2014 at 12:30 PM, Gordon Keiser <gkeiser at arxan.com> wrote:
> I’m not sure what the original symptoms of this were, a quick build
> changing the enum definition to
>
>
>
> enum fltCategory : unsigned {
>
>
>
> and the bitfield to 2 bits didn’t produce any immediately obvious problems
> in the bitcode or output assembly with various floats in use. I don’t have
> time to run more tests against it ATM. Since this is C++11 compatible and
> probably more correct, anyway, it seems like the way to do it.
>
>
>
> -Gordon
>
>
>
> *From:* llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] *On
> Behalf Of *Gordon Keiser
> *Sent:* Tuesday, March 18, 2014 2:35 PM
> *To:* Pete Cooper; LLVM Developers Mailing List
> *Subject:* Re: [LLVMdev] Virtual Studio hack in APFloat.h
>
>
>
> The comment on this says:
>
> /// Only 2 bits are required, but VisualStudio incorrectly sign extends
> it.
>
> /// Using the extra bit keeps it from failing under VisualStudio.
>
> fltCategory category : 3;
>
>
>
> Which I don’t think is correct, since the standard doesn’t specify whether
> a pre-C++11 (untyped) enum needs to be signed or unsigned. Specifying the
> enum as enum unsigned should work for VS2012, I can try this a bit later
> and see if it works.
>
>
>
> -Gordon
>
>
>
> *From:* llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu<llvmdev-bounces at cs.uiuc.edu>]
> *On Behalf Of *Pete Cooper
> *Sent:* Tuesday, March 18, 2014 2:15 PM
> *To:* LLVM Developers Mailing List
> *Subject:* [LLVMdev] Virtual Studio hack in APFloat.h
>
>
>
> Hi all
>
>
>
> APFloat.h contains this code, which was required for Visual Studio builds.
>
>
>
> Given that this was committed in r41784 (2007), does anyone know if newer
> versions work? I think after moving to C++11 we’re on VS2013 at a minimum?
> I’d have hoped it would be more likely to work.
>
>
>
> Thanks,
>
> Pete
>
>
>
> /// What kind of floating point number this is.
>
> ///
>
> /// Only 2 bits are required, but VisualStudio incorrectly sign extends
> it.
>
> /// Using the extra bit keeps it from failing under VisualStudio.
>
> fltCategory category : 3;
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140325/4e71bdbe/attachment.html>
More information about the llvm-dev
mailing list