Skip to content

Commit 8eb9ff7

Browse files
Merge pull request #109 from goblint/issue_91
Allow casts from any type to `void`
2 parents a8b4da7 + 875d3a4 commit 8eb9ff7

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

src/frontc/cabs2cil.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1416,7 +1416,7 @@ let rec castTo ?(fromsource=false)
14161416
result
14171417

14181418
(* The expression is evaluated for its side-effects *)
1419-
| (TInt _ | TEnum _ | TPtr _ ), TVoid _ ->
1419+
| _ , TVoid _ ->
14201420
(ot, e)
14211421

14221422
(* Even casts between structs are allowed when we are only

test/small1/c99-tgmath2.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include <stdio.h>
2+
#include <tgmath.h>
3+
#include <complex.h>
4+
#include "testharness.h"
5+
6+
typedef struct loc_t
7+
{
8+
long nloc;
9+
} loc_t;
10+
11+
12+
void fun(const loc_t* loc) {
13+
long l =8;
14+
int n0 =(int)sqrt(l); // works
15+
int n1 =(int)sqrt(loc->nloc); // fails
16+
}
17+
18+
19+
int main() {
20+
loc_t loc;
21+
loc.nloc = 5;
22+
loc_t* ptr = &loc;
23+
fun(ptr);
24+
SUCCESS;
25+
}

test/testcil.pl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,7 @@ sub addToGroup {
695695
addTest("testrunc99/c99-universal-character-names");
696696

697697
addTest("testrunc99/c99-tgmath");
698+
addTest("testrunc99/c99-tgmath2");
698699
addTest("testrunc99/c99-float-pragma");
699700
addTest("testrunc99/c99-fixed-width-int");
700701
addTest("combinec99inline");

0 commit comments

Comments
 (0)