Skip to content
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

cgen: cannot convert int to struct string #23498

Closed
wants to merge 1 commit into from

Conversation

trufae
Copy link
Contributor

@trufae trufae commented Jan 17, 2025

This is just a workaround for something that shouldnt be necessary if the codegen worked well, but i'm pushing it as a PR for testing. Compiling v-r2pipe results in this error:

v-r2pipe$ make
v -show-c-output -shared .
======== Output of the C Compiler (/home/pancake/prg/v/thirdparty/tcc/tcc.exe) ========
/tmp/v_1000/v-r2pipe.01JHSX9DHAW6TD23X9GFMN9BFJ.tmp.so.c:16029: warning: implicit declaration of function 'IError_str'
/tmp/v_1000/v-r2pipe.01JHSX9DHAW6TD23X9GFMN9BFJ.tmp.so.c:16029: warning: assignment makes pointer from integer without a cast
/tmp/v_1000/v-r2pipe.01JHSX9DHAW6TD23X9GFMN9BFJ.tmp.so.c:16029: warning: cast between pointer and integer of different size
/tmp/v_1000/v-r2pipe.01JHSX9DHAW6TD23X9GFMN9BFJ.tmp.so.c:17034: error: cannot convert 'int' to 'struct string'
=======================================================================================
======== Output of the C Compiler (cc) ========
/tmp/v_1000/v-r2pipe.01JHSX9DHAW6TD23X9GFMN9BFJ.tmp.so.c: In function ‘os__mkdir_all’:
/tmp/v_1000/v-r2pipe.01JHSX9DHAW6TD23X9GFMN9BFJ.tmp.so.c:16029:189: warning: implicit declaration of function ‘IError_str’ [-Wimplicit-function-declaration]
16029 |                         return (_result_void){ .is_error=true, .err=_v_error(str_intp(3, _MOV((StrIntpData[]){{_SLIT("folder: "), 0xfe10, {.d_s = p}}, {_SLIT(", error: "), 0xfe10, {.d_s = IError_str(err)}}, {_SLIT0, 0, { .d_c = 0 }}}))), .data={EMPTY_STRUCT_INITIALIZATION} };
      |                                                                                                                                                                                             ^~~~~~~~~~
/tmp/v_1000/v-r2pipe.01JHSX9DHAW6TD23X9GFMN9BFJ.tmp.so.c:16029:189: warning: initialization of ‘u8 *’ {aka ‘unsigned char *’} from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
/tmp/v_1000/v-r2pipe.01JHSX9DHAW6TD23X9GFMN9BFJ.tmp.so.c:16029:189: note: (near initialization for ‘(anonymous)[1].d.d_s.str’)
/tmp/v_1000/v-r2pipe.01JHSX9DHAW6TD23X9GFMN9BFJ.tmp.so.c: In function ‘os__Process_unix_spawn_process’:
/tmp/v_1000/v-r2pipe.01JHSX9DHAW6TD23X9GFMN9BFJ.tmp.so.c:17034:26: error: incompatible type for argument 1 of ‘eprintln’
17034 |                 eprintln(IError_str(err));
      |                          ^~~~~~~~~~~~~~~
      |                          |
      |                          int
/tmp/v_1000/v-r2pipe.01JHSX9DHAW6TD23X9GFMN9BFJ.tmp.so.c:8095:22: note: expected ‘string’ but argument is of type ‘int’
 8095 | void eprintln(string s) {
      |               ~~~~~~~^
/tmp/v_1000/v-r2pipe.01JHSX9DHAW6TD23X9GFMN9BFJ.tmp.so.c: In function ‘r2pipe__R2Pipe_on’:
/tmp/v_1000/v-r2pipe.01JHSX9DHAW6TD23X9GFMN9BFJ.tmp.so.c:17425:17: warning: braces around scalar initializer
17425 |                 .th = {0},
      |                 ^
/tmp/v_1000/v-r2pipe.01JHSX9DHAW6TD23X9GFMN9BFJ.tmp.so.c:17425:17: note: (near initialization for ‘(anonymous).th’)
===============================================

to reproduce:

git clone https://github.com/radare/v-r2pipe
cd v-r2pipe
make

Copy link

Connected to Huly®: V_0.6-21927

@felipensp
Copy link
Member

It's a bug on -skip-unused feature that was enabled by default. A simple workaround is just use -no-skip-unused for a moment.

@felipensp
Copy link
Member

I can be reproduced by:

import os

fn main() {
	mut proc := os.Process{}
	proc.run()
}

@felipensp
Copy link
Member

I've provided a fix in #23499

@spytheman
Copy link
Member

@trufae, please check if latest V works for you. I've merged #23499 .

@spytheman
Copy link
Member

I'll close that, till you check. If there are remaining problems, feel free, to file new issues/PRs, or to reopen this one.

@spytheman spytheman closed this Jan 18, 2025
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.

4 participants