Passing variable with name stderr into closure causes c compilation error #22262
Labels
Bug
This tag is applied to issues which reports bugs.
Status: Confirmed
This bug has been confirmed to be valid by a contributor.
Unit: cgen
Bugs/feature requests, that are related to the default C generating backend.
Describe the bug
Passing a variable with the names
stdin
,stdout
, orstderr
into a closure causes c compilation error.Reproduction Steps
This should reproduce the bug:
Expected Behavior
when
causes_error
is called it should do nothing but change the value ofstderr
to 1Current Behavior
with
v .
with
-cg
flag:Possible Solution
Seems to be related to any variable with the name
stdin
,stdout
, orstderr
being passed into a closure.Further investigation reveals that the closure's context struct is exported with the original variable name as field,
but then this generates a 'sanitized' name("__v_" + varname) to prevent reserved name colision. Somehow the var name
must be also be 'sanitized' when output elsewhere. (see Additional Info/Context)
Additional Information/Context
This is the generated c file(with another non error causing function; same code different variable names). There seems to be some issue with mangling the variable name into
__v_stderr
(to prevent a conflict?) but not doing that in the struct field.V version
V 0.4.7 9a0f4d8
Environment details (OS name and version, etc.)
Note
You can use the 👍 reaction to increase the issue's priority for developers.
Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.
The text was updated successfully, but these errors were encountered: