#108 bitsSizeOf TEnum is wrong

Bug
closed
nobody
5
2011-09-22
2009-06-03
Anonymous
No

bitsSizeOf TEnum is wrong in cil.ml in 1.3.7 and subversion trunk revision 10813. Test case is attached. Patch here:

Index: src/cil.ml

--- src/cil.ml (revision 10813)
+++ src/cil.ml (working copy)
@@ -2385,7 +2385,7 @@
| TFloat(FDouble, _) -> 8 * !M.theMachine.M.sizeof_double
| TFloat(FLongDouble, _) -> 8 * !M.theMachine.M.sizeof_longdouble
| TFloat _ -> 8 * !M.theMachine.M.sizeof_float
- | TEnum (ei, _) -> 8 * (bitsSizeOf (TInt(ei.ekind, [])))
+ | TEnum (ei, _) -> 8 * !M.theMachine.M.sizeof_enum
| TPtr _ -> 8 * !M.theMachine.M.sizeof_ptr
| TBuiltin_va_list _ -> 8 * !M.theMachine.M.sizeof_ptr
| TNamed (t, _) -> bitsSizeOf t.ttype

Discussion

  • Nobody/Anonymous

    test case

     
  • Nobody/Anonymous

    This might not be the best fix. Perhaps it would be better to just remove the multiplication by 8.

    However, why does theMachine contain the field sizeof_enum if it's not being used?

     
  • Ben Liblit

    Ben Liblit - 2009-11-09

    I agree that a better fix is to remove the multiplication by 8, so that we simply have:

    | TEnum (ei, _) -> bitsSizeOf (TInt(ei.ekind, []))

    Regarding the question of why "theMachine.M.sizeof_enum" is needed at all, this seems to be a historical artifact left over from before "enuminfo.ekind" was introduced. I see no other uses of "theMachine.M.sizeof_enum", so it seems this can now be removed entirely along with the configuration-time tests that compute it.

     
  • Gabriel Kerneis

    Gabriel Kerneis - 2011-09-22

    Fixed in trunk a long time ago (Zachary R. Anderson <zra@cs.berkeley.edu> 2009-07-24 02:39:56)

     
  • Gabriel Kerneis

    Gabriel Kerneis - 2011-09-22
    • status: open --> closed
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks