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
Inconsistent behavior with str
and &str[0]
#1148
Comments
Based on section 2.5.1 of the Checked C spec, I believe that the compiler is exhibiting the expected behavior here. 2.5.1 Rules for the address-of operator
Since the function If we create a dummy version of
|
Thanks for the explanation. On reflection, I don't understand why rule 2.5.1 makes sense. Can you explain why being in a checked block changes the behavior of I would posit that programmers will expect that in any circumstance
Why does Checked C seem to do one thing for singleton pointers but something else for array pointers? For arrays, |
If we pass
Starting at line 14044 of SemaExpr.cpp, there is logic for implementing C99 address-of rules: if an expression |
OK sounds like we are on the same page. It would be interesting if this issue ultimately owes to lack of coverage in the C99 spec! |
@kkjeer Any update on this? |
@mwhicks1 sorry for the delay! I've created PRs in checkedc-clang and checkedc for this issue and am running tests on them now. |
Great! Thanks for taking care of this. |
For this code
The
stdio_checked.h
file definessprintf
's first argument to be achar *
. As such, passingstr
to it is rejected as incompatible (passing a checked type where an unchecked one was expected). But the second line is accepted, even though it is passing literally the same address tosprintf
as the first. (The first line is accepted if you add an unsafe cast, e.g.,sprintf((char *)str,"%s","hello");
)The text was updated successfully, but these errors were encountered: