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

Improve error for assigning to const #422

Open
Vexu opened this issue Nov 17, 2022 · 0 comments
Open

Improve error for assigning to const #422

Vexu opened this issue Nov 17, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@Vexu
Copy link
Owner

Vexu commented Nov 17, 2022

int foo(void) {
    const int a;
    a = 1;
    return a;
}

Arocc output:

./a.c:40:7: error: expression is not assignable
    a = 1;
      ^
1 error generated.

Clang output:

a.c:40:7: error: cannot assign to variable 'a' with const-qualified type 'const int'
    a = 1;
    ~ ^
a.c:39:15: note: variable 'a' declared const here
    const int a;
    ~~~~~~~~~~^
1 error generated.
@Vexu Vexu added the enhancement New feature or request label Nov 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant