diff --git a/src/frontc/cabs2cil.ml b/src/frontc/cabs2cil.ml index fbfea3997..d25ad69a8 100644 --- a/src/frontc/cabs2cil.ml +++ b/src/frontc/cabs2cil.ml @@ -1416,7 +1416,7 @@ let rec castTo ?(fromsource=false) result (* The expression is evaluated for its side-effects *) - | (TInt _ | TEnum _ | TPtr _ ), TVoid _ -> + | _ , TVoid _ -> (ot, e) (* Even casts between structs are allowed when we are only diff --git a/test/small1/c99-tgmath2.c b/test/small1/c99-tgmath2.c new file mode 100644 index 000000000..8d1b2798b --- /dev/null +++ b/test/small1/c99-tgmath2.c @@ -0,0 +1,25 @@ +#include +#include +#include +#include "testharness.h" + +typedef struct loc_t +{ + long nloc; +} loc_t; + + +void fun(const loc_t* loc) { + long l =8; + int n0 =(int)sqrt(l); // works + int n1 =(int)sqrt(loc->nloc); // fails +} + + +int main() { + loc_t loc; + loc.nloc = 5; + loc_t* ptr = &loc; + fun(ptr); + SUCCESS; +} diff --git a/test/testcil.pl b/test/testcil.pl index 7589d1eaa..0df228f70 100644 --- a/test/testcil.pl +++ b/test/testcil.pl @@ -695,6 +695,7 @@ sub addToGroup { addTest("testrunc99/c99-universal-character-names"); addTest("testrunc99/c99-tgmath"); +addTest("testrunc99/c99-tgmath2"); addTest("testrunc99/c99-float-pragma"); addTest("testrunc99/c99-fixed-width-int"); addTest("combinec99inline");