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

const can be specified for a function argument more than once #729

Open
Daniel-Cortez opened this issue Jan 21, 2024 · 0 comments
Open

const can be specified for a function argument more than once #729

Daniel-Cortez opened this issue Jan 21, 2024 · 0 comments

Comments

@Daniel-Cortez
Copy link
Contributor

Issue description:

While working on an implementation of named-only function arguments (#719), I found an oversight in function declargs().

compiler/source/compiler/sc1.c

Lines 4278 to 4282 in 81b4a02

case tCONST:
if (ident!=iVARIABLE || numtags>0 || fpragma)
error(1,sc_tokens[tSYMBOL-tFIRST],sc_tokens[tCONST-tFIRST]);
fconst=TRUE;
break;

There's no check if const was already specified, although handlers for other specifiers (&, Tag:, ...) have this kind of check.
As a result, the user can specify const any number of times

Func(const const const const arg) {}

and the compiler would think this is okay, although it clearly isn't.

Minimal complete verifiable example (MCVE):

See above.

Workspace Information:

  • Compiler version: 3.10.10
  • Command line arguments provided (or sampctl version): Not relevant.
  • Operating System: Not relevant.
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