liballocs icon indicating copy to clipboard operation
liballocs copied to clipboard

[CIL] Miscellaneous Parse Errors

Open difcsi opened this issue 4 months ago • 1 comments

Following yesterday's discussions about CIL, I decided to spend a coffee break today to try to break it. I discovered some parse errors, some of which are fixed by goblint-cil. I'm not quite sure which C standard Stephen-Cil targets but #129 mentions work on C23, so most of these could be relevant.

Errors on C11, commit 1adb5c6e6b1f2ac29aeed1127bb47d51e36d2ad4

Type Switches

Works on Goblint CIL

int type_switch(){
	int a = _Generic((1), int: (1), default: (1));
	return 0;
}

Digraphs

Parse error on Goblint CIL as well

int digraphs()<% 
    int c = 0;
%>

Anonymous union member

Parse error on Goblint CIL as well

struct S {union { int x; float f};}; 

Complex number macros

Parse error on Goblint CIL as well

#include <complex.h>
double complex z = 1.0 + 2.0*I;

Offsetof

Parse error on Goblint CIL as well

struct S { int x; float f; } s;
int offs =  offsetof(struct S, x);

Below this, GNU extensions

Statement expression

Parse error on Goblint CIL as well

int x = ({ int t = 2; t*t; });

Computed Goto labels

Parse error on Goblint CIL as well

void *labels[] = { &&L1, &&L2 };
goto *labels[i];

alignas, alternative token for align_as

Works on Goblint CIL

alignas(32) char buf[64];

difcsi avatar Oct 22 '25 11:10 difcsi

Thanks Zoltan. So I think the only things Goblint has in the above are alignas and _Generic. For the rest, it may be worth reporting them on Goblint if they do not already have issues open.

CIL does not target a specific version of C. It is nominally intended to work with any, from K&R onwards, and including GNU extensions... although the more modern, the more chance of running into unimplemented features like the above.

Ultimately, like most of the infrastructure we build, it exists to serve the research results we want it to demonstrate. If we have not run into these features in any codebase that matters to us, we most likely will not want to put the resource eagerly into implementing them. I suspect the Goblint project works the same way.

stephenrkell avatar Oct 23 '25 16:10 stephenrkell