Skip to content

Bit-field initialization via interpreter still has problems #499

Description

@Geoffrey1014

When I use ccomp -interp , i encounter a UB problem about bitfield. I also notice #22, it should be fixed, but not.

// test.ctypedefstructS1 {
signedf0:32;
} t;
tg_1= {0};
intmain(){
g_1.f0=1;
tl_1= {0};
l_1.f0=1;
inta=2;
return1;
}
$ccomp --version
The CompCert C verified compiler, version 3.11
$ccomp -interp -fall -trace test.c
Time 0: calling main()
--[step_internal_function]-->
Time 1: infunctionmain, statement
g_1.f0 = 1; l_1.f0 = 0; l_1.f0 = 1; a = 2;return 1;return 0;
--[step_seq]-->
Time 2: infunctionmain, statement
g_1.f0 = 1; l_1.f0 = 0; l_1.f0 = 1; a = 2;return 1;
--[step_seq]-->
Time 3: infunctionmain, statement g_1.f0 = 1;
--[step_do_1]-->
Time 4: infunctionmain, expression g_1.f0 = 1
--[red_var_global]-->
Time 5: infunctionmain, expression <loc g_1>.f0 = 1
--[red_rvalof]-->
Time 6: infunctionmain, expression <ptr g_1>.f0 = 1
--[red_field_struct]-->
Time 7: infunctionmain, expression <loc g_1> = 1
--[red_assign]-->
Time 8: infunctionmain, expression 1
--[step_do_2]-->
Time 9: infunctionmain, statement /*skip*/;
--[step_skip_seq]-->
Time 10: infunctionmain, statement l_1.f0 = 0; l_1.f0 = 1; a = 2;return 1;
--[step_seq]-->
Time 11: infunctionmain, statement l_1.f0 = 0;
--[step_do_1]-->
Time 12: infunctionmain, expression l_1.f0 = 0
--[red_var_local]-->
Time 13: infunctionmain, expression <loc l_1>.f0 = 0
--[red_rvalof]-->
Time 14: infunctionmain, expression <ptr l_1>.f0 = 0
--[red_field_struct]-->
Time 15: infunctionmain, expression <loc l_1> = 0
Stuck state: infunctionmain, expression <loc l_1> = 0
Stuck subexpression: <loc l_1> = 0
ERROR: Undefined behavior

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions