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

Builtin definitions (and functions with a body) should always be const unless prefixed by var #211

Open
divVerent opened this issue Nov 3, 2024 · 1 comment

Comments

@divVerent
Copy link
Contributor

divVerent commented Nov 3, 2024

gmqcc permits this code, whereas fteqcc does not:

void() foo = #1;

void() bar = {
	foo = bar;
};

fteqcc's error:

foo.qc:4: warning Q106: Assignment to const
foo.qc:1:    const void() foo is defined here
foo.qc:4: warning Q106: Assignment to constant foo
foo.qc:1:    const void() foo is defined here

OTOH gmqcc refuses this code, whereas fteqcc allows it:

void() foo_builtin = #1;
var void() foo = foo_builtin;

void() bar = {
	foo = bar;
};

gmqcc's error:

foo.qc:2:24: error: initializer is non constant

I think the problem is that builtin definitions aren't const in gmqcc, but should be. The issue reproduces equally if the functions have a body instead of a builtin, and also equally when using C-style function declarations, and regardless of -std=.

@divVerent
Copy link
Contributor Author

Filed https://gitlab.com/xonotic/xonotic-data.pk3dir/-/merge_requests/1380 for Xonotic to decide how to prepare for fixing this bug.

nyov pushed a commit to xonotic/xonotic-data.pk3dir that referenced this issue Nov 3, 2024
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

No branches or pull requests

1 participant