Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/frontc/cabs2cil.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 25 additions & 0 deletions test/small1/c99-tgmath2.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include <stdio.h>
#include <tgmath.h>
#include <complex.h>
#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;
}
1 change: 1 addition & 0 deletions test/testcil.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down