[LLVMdev] Virtual Studio hack in APFloat.h

Gordon Keiser gkeiser at arxan.com
Thu Mar 20 12:30:01 PDT 2014


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> [mailto: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;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140320/1f3ae88d/attachment.html>


More information about the llvm-dev mailing list