Skip to content

C error printing the reference of a not integer variable. #23461

Description

@jorgeluismireles

Describe the bug

We have a variable other than int, we create a reference and tried to print the reference.

Reproduction Steps

fn main() {
	s := 'Hello'
	p := &s
	println('${p}')
}

If above s is int or u8 there is no error and prints a number. If s is rune or f32 also there is a C error.

Expected Behavior

Get the number of the address (like with an integer).

Current Behavior

Running code...
Can't run code. The server returned an error:
/tmp/v_60000/../../../../../../box/code.v:4: warning: implicit declaration of function 'isnil'
/home/admin/v/thirdparty/tcc/lib/libgc.a: error: 'GC_noop1_ptr' defined twice
tcc: error: undefined symbol 'isnil'
builder error: 
==================
C error found. It should never happen, when compiling pure V code.
This is a V compiler bug, please report it using `v bug file.v`,
or goto https://github.com/vlang/v/issues/new/choose .
You can also use #help on Discord: https://discord.gg/vlang .
Exited with error status 1
Please try again.

Possible Solution

Related with this issue #23460

Additional Information/Context

In REPL is harmless:

____    ____ 
 \   \  /   /  |  Welcome to the V REPL (for help with V itself, type  exit , then run  v help ).
  \   \/   /   |  Note: the REPL is highly experimental. For best V experience, use a text editor, 
   \      /    |  save your code in a  main.v  file and execute:  v run main.v 
    \    /     |  V 0.4.9 6f7cbd1 . Use  list  to see the accumulated program so far.
     \__/      |  Use Ctrl-C or  exit  to exit, or  help  to see other available commands.

>>> s := 'Hello'
>>> p := &s
>>> println('${p}')
&Hello
>>> 

V version

V 0.4.9 a20fff9

Environment details (OS name and version, etc.)

https://play.vlang.io/p/04a4c8aab1

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugThis tag is applied to issues which reports bugs.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions