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 error for x := 5 * p where p is &int #21513

Closed
spytheman opened this issue May 16, 2024 · 2 comments · Fixed by #21515
Closed

cgen error for x := 5 * p where p is &int #21513

spytheman opened this issue May 16, 2024 · 2 comments · Fixed by #21515
Assignees
Labels
Bug This tag is applied to issues which reports bugs. Unit: Checker Bugs/feature requests, that are related to the type checker. Unit: Compiler Bugs/feature requests, that are related to the V compiler in general. Unit: Type System Bugs/feature requests, that are related to the V types system.

Comments

@spytheman
Copy link
Member

spytheman commented May 16, 2024

V doctor:

V full version: V 0.4.5 387af74.9639f55
OS: macos, macOS, 14.4.1, 23E224
Processor: 8 cpus, 64bit, little endian, Apple M1

getwd: /opt/v
vexe: /opt/v/v
vexe mtime: 2024-05-16 12:27:51

vroot: OK, value: /opt/v
VMODULES: OK, value: /Users/delyanangelov/.vmodules
VTMP: OK, value: /tmp/v_501

Git version: git version 2.44.0
Git vroot status: weekly.2024.20-2-g9639f55d
.git/config present: true

CC version: Apple clang version 15.0.0 (clang-1500.3.9.4)
thirdparty/tcc status: thirdparty-macos-arm64 5c1d002f

What did you do?
v -g -o vdbg cmd/v && vdbg a.v

num := 10
p := &num
x := 5 *p
dump(x)
dump(p)

What did you expect to see?

a checker error, that pointers can not be multiplied by constants

What did you see instead?

==================
/tmp/v_501/a.01HY0NZYP771Q1E3V55HB4ZNRS.tmp.c:13037:13: error: invalid operands to binary expression ('int' and 'int *')
        int* x = 5 * p;
                 ~ ^ ~
1 error generated.
...
==================
(Use `v -cg` to print the entire error message)

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 .

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.

@spytheman spytheman added Bug This tag is applied to issues which reports bugs. Unit: Compiler Bugs/feature requests, that are related to the V compiler in general. Unit: Type System Bugs/feature requests, that are related to the V types system. Unit: Checker Bugs/feature requests, that are related to the type checker. labels May 16, 2024
@spytheman
Copy link
Member Author

spytheman commented May 16, 2024

x := 5 *p should have been a checker error instead.

Multiplying a pointer by a number, should not be allowed.

@spytheman
Copy link
Member Author

Only + and - should be allowed as arithmetic operators for pointer values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This tag is applied to issues which reports bugs. Unit: Checker Bugs/feature requests, that are related to the type checker. Unit: Compiler Bugs/feature requests, that are related to the V compiler in general. Unit: Type System Bugs/feature requests, that are related to the V types system.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants