-
Notifications
You must be signed in to change notification settings - Fork 265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
C front-end: hide our use of single-bit bool within sizeof #5723
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #5723 +/- ##
========================================
Coverage 73.55% 73.55%
========================================
Files 1431 1431
Lines 155248 155248
========================================
Hits 114189 114189
Misses 41059 41059
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wasn't this why there was a distinction between bool
and c_bool
. I thought they were 1 bit and 8 bit respectively and C defaulted to generating c_bool
with __CPROVER_bool
needed to generate actual ID_bool
. Perhaps I have got very confused.
src/ansi-c/c_typecheck_expr.cpp
Outdated
(op.id() == ID_not || op.id() == ID_and || op.id() == ID_or || | ||
op.id() == ID_equal || op.id() == ID_notequal || op.id() == ID_lt || | ||
op.id() == ID_le || op.id() == ID_gt || op.id() == ID_ge || | ||
op.id() == ID_if)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would probably drop the check of the operator.
Say ?: is missing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's ID_if
in the above, but I agree this could easily be missing some other operator. When writing this code I was wondering whether to just always cast, or whether some cases should be considered illformed input and be rejected by the type checker?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's the right thing to always use int
whenever "proper bool" is encountered in sizeof
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, done!
You are absolutely right, except the C front-end nowadays readily makes various "Boolean" operations (such as comparisons) a |
In C, Boolean operations are of type int. Rejecting sizeof expressions of Boolean operations breaks building the Linux kernel.
In C, Boolean operations are of type int. Rejecting sizeof expressions
of Boolean operations breaks building the Linux kernel.