Skip to content

C front-end fixes - #625

Open
xavierleroy wants to merge 5 commits into
masterfrom
fixes-frontend
Open

xavierleroy wants to merge 5 commits into
masterfrom
fixes-frontend

Conversation

@xavierleroy

Copy link
Copy Markdown
Contributor

This PR fixes one significant issue with array members of volatile structs and unions, plus some minor departures from the C11 standard.

Several of these issues were reported by Christos Papakonstantinou (Cantina Security).

Evaluating both arguments of `||` and `&&` before checking their Boolean
values leads to rejecting e.g. `1 || (1/0)` and `0 || (1/0)`, despite
these expressions having well-defined, constant values.

Also, the previous implementation of Ceval mis-handled arguments of `||`/'&&'
that are 64-bit integers.  E.g. `(1ULL << 32) && 1` was 0
instead of the correct 1.
…targets

For format `p` and modifiers `z` and `t`, 64-bit platforms use `Vlong` values
while 32-bit platforms use `Vint` values.  Let's handle both.
If a struct or union is volatile and has a member of array type `t[N]`,
accessing this member must add the volatile modifier not just to
the type `t[N]` but also to the type `t`.  Otherwise, the decay of `t[N]`
to `*t` loses the volatile information.

This was correctly done in the unverified elaborator (cparse/) but not
in the verified type-checker (cfrontend/Ctyping.v).
If a plain string literal is concatenated with a wide empty literal,
the plain string becomes a wide string.
A literal of small unsigned integer type is still promoted to `signed int`.

The only case where it makes a difference is u16 character literals and
wide character literals on platforms where `wchar_t` is `unsigned short`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant