Hi, Here’s the question for libgccjit on pointer arithmetic. There’s error for type mismatching with char* and int. Please see full code at https://github.com/yli137/libgccjit_test Thank you Yicheng Li On Mar 20, 2023, at 3:32 PM, Basile Starynkevitch wrote: You don't often get email from basile@starynkevitch.net. Learn why this is important Improve your C code to have a full routine or program, then post it on the mailing list (better yet, make your code open source on https://github.com/ ....) On 20/03/2023 20:30, Li, Yicheng wrote: Hi, Here’s the code in C. Basically, I have two params, both in char *. And I want to do pointer arithmetic on them. gcc_jit_type *char_type, *char_ptr_type,, *sizet_type, *int_type; char_type = gcc_jit_context_get_type( ctxt, GCC_JIT_TYPE_CHAR ); sizet_type = gcc_jit_context_get_type( ctxt, GCC_JIT_TYPE_SIZE_T ); int_type = gcc_jit_context_get_type( ctxt, GCC_JIT_TYPE_INT ); char_ptr_type = gcc_jit_type_get_pointer( char_type ); gcc_jit_lvalue *dst_val = gcc_jit_function_new_local( func, NULL, char_ptr_type, "dst_val" ), *src_val = gcc_jit_function_new_local( func, NULL, char_ptr_type, "src_val” ); gcc_jit_block_add_assignment( block, NULL, dst_val, gcc_jit_param_as_rvalue( param[0] ) ); gcc_jit_block_add_assignment( block, NULL, src_val, gcc_jit_param_as_rvalue( param[1] ) ); gcc_jit_context_new_binary_op( ctxt, NULL, GCC_JIT_BINARY_OP_PLUS, char_ptr_type, gcc_jit_lvalue_as_rvalue( dst_val ), gcc_jit_context_new_rvalue_from_long( ctxt, sizet_type, 10 ) ); gcc_jit_context_new_binary_op( ctxt, NULL, GCC_JIT_BINARY_OP_PLUS, char_ptr_type, gcc_jit_lvalue_as_rvalue( src_val ), gcc_jit_context_new_rvalue_from_long( ctxt, sizet_type, 10 ) ); The error is follows: libgccjit.so: error: gcc_jit_context_new_binary_op: mismatching types for binary op: a: dst_val (type: char *) b: (size_t)0 (type: size_t) libgccjit.so: error: gcc_jit_context_new_binary_op: mismatching types for binary op: a: src_val (type: char *) b: (size_t)0 (type: size_t) Thank you Yicheng Li On Mar 20, 2023, at 3:24 PM, Basile Starynkevitch wrote: You don't often get email from basile@starynkevitch.net. Learn why this is important You asked > > How to do pointer arithmetic in libgccjit? I created a pointer type > (char *) and an integer type (int or size_t or long). When I use > gcc_jit_context_binary_op with GCC_JIT_BINARY_OP_PLUS, it’s giving me > error as mismatching types of (char*) and (int). Is pointer > arithmetic viable in libgccjit? but I recommend to show some real C++ code in your question.... And the warnings you obtained. BTW, you can construct pointer types in GCCJIT. gcc_jit_type_get_pointer Alternatively, generate some temporary C code and use GCC to compile it as a plugin (see https://arxiv.org/abs/1109.0779v1 - it used to work) My pet open source project is http://refpersys.org/ (inference engine) and we hope to generate code from higher level rules, like explained in Jacques Pitrat(s last book. https://en.wikipedia.org/wiki/Jacques_Pitrat Regards -- Basile Starynkevitch (only mine opinions / les opinions sont miennes uniquement) 92340 Bourg-la-Reine, France web page: starynkevitch.net/Basile/ & refpersys.org -- Basile Starynkevitch (only mine opinions / les opinions sont miennes uniquement) 92340 Bourg-la-Reine, France web page: starynkevitch.net/Basile/ & refpersys.org