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
missing constCast in c fn call cause compiler error without any tips and notes #19781
Comments
Could you provide a code sample that reproduces this issue? |
c.XSetIMValues(null, c.XNDestroyCallBack, &c.XIMCallback{.client_data=null, .callback=null}, c.NULL) the workaround is: |
There's still not enough context here to help diagnose what is going on - do you have a link to a repo we could look at? At first glance it looks like you're taking the address of a temporary variable (via |
@ehaas @silversquirl here is the problem: _ = std.c.printf("format", .{"abc"}); _ = std.c.printf("format", @constcast(&.{"abc"})); // this is ok |
Stack Trace
My personal opinion is that array init without an explicit type should be illegal in varargs. |
the problem seems to be that you can't use a temporary variable in a va_list, unless it's a @constcast modified pointer |
The examples above trigger an assertion in handling @unisgn, the issue is not directly related to |
let me show some more case. const S = struct {a: u8=0}; _ = std.c.printf("", var_s, // fail#1 with some tips &var_s, // ok#1 &S{}, // fail#3 without any tips .{"str"}, // fail#4 without any tips here is my question: note |
Varargs aren't as tested as they should be! I might quickly put a PR up to fix this in a bit. |
This was a "fake" type used to handle C varargs parameters, much like generic poison. In fact, it is treated identically to generic poison in all cases other than one (the final coercion of a call argument), which is trivially special-cased. Thus, it makes sense to remove this special tag and instead use `generic_poison_type` in its place. This fixes several bugs in Sema related to missing handling of this tag. Resolves: ziglang#19781
Great job. But i have no idea how to cc about the coerce_ptr_elem_ty you said
…---- Replied Message ----
| From | Matthew ***@***.***> |
| Date | 05/02/2024 08:30 |
| To | ziglang/zig ***@***.***> |
| Cc | oxfrancis ***@***.***>,
Author ***@***.***> |
| Subject | Re: [ziglang/zig] missing constCast in c fn call cause compiler error without any tips and notes (Issue #19781) |
bug (the one I described above)
bug (cc anyone working on this: coerce_ptr_elem_ty also needs a fix)
it's a bug that fail#3 fails
Varargs aren't as tested as they should be! I might quickly put a PR up to fix this in a bit.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Sorry, I only write "cc" to indicate a note in my comment to another party (in this case to whoever ends up working on the fix). It's not relevant to you, and since I've fixed the issue in #19835 (currently failing CI but it is a fix), it didn't end up being relevant to anyone else either! |
This was a "fake" type used to handle C varargs parameters, much like generic poison. In fact, it is treated identically to generic poison in all cases other than one (the final coercion of a call argument), which is trivially special-cased. Thus, it makes sense to remove this special tag and instead use `generic_poison_type` in its place. This fixes several bugs in Sema related to missing handling of this tag. Resolves: ziglang#19781
This was a "fake" type used to handle C varargs parameters, much like generic poison. In fact, it is treated identically to generic poison in all cases other than one (the final coercion of a call argument), which is trivially special-cased. Thus, it makes sense to remove this special tag and instead use `generic_poison_type` in its place. This fixes several bugs in Sema related to missing handling of this tag. Resolves: ziglang#19781
This was a "fake" type used to handle C varargs parameters, much like generic poison. In fact, it is treated identically to generic poison in all cases other than one (the final coercion of a call argument), which is trivially special-cased. Thus, it makes sense to remove this special tag and instead use `generic_poison_type` in its place. This fixes several bugs in Sema related to missing handling of this tag. Resolves: #19781
Zig Version
0.12.0
Steps to Reproduce and Observed Behavior
after the recent feature in 0.12, never mutated local variable will cause a compiler error "local variable is never mutated", with note "consider using const".
but if it happens in a c function call where missing a constCast, the compiler gives no note, just fails, make it hard to locate the causing.
Expected Behavior
just gives some notes on error
The text was updated successfully, but these errors were encountered: