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

[Bug]: const ref attached to vararg formal arguments allows their modification #25901

Open
lydia-duncan opened this issue Sep 6, 2024 · 0 comments · May be fixed by #25902
Open

[Bug]: const ref attached to vararg formal arguments allows their modification #25901

lydia-duncan opened this issue Sep 6, 2024 · 0 comments · May be fixed by #25902

Comments

@lydia-duncan
Copy link
Member

lydia-duncan commented Sep 6, 2024

Summary of Problem

Description:
This is the remaining issue tracked by #25858 which I wasn't able to solve yet.

The individual arguments passed to a const ref varargs should behave the same as though they were passed to a const ref tuple or individually - they should trigger an error about modifying a const if the body of the function tries to modify them. However, today a program that does so compiles without issue and allows modification to occur.

This was easily solved for const and const in, but const ref for some reason is proving more elusive.

Is this issue currently blocking your progress?
No, just tracking it

Steps to Reproduce

Source Code:

proc myPrintln(const ref args...)
{
  writeln("args.type     = ", args.type:string);
  writeln("args (before) = ", args);

  args[0] *= 10;  // should not be allowed

  writeln("args (after) = ", args);
}

myPrintln(1, 2.3, "four");

Compile command:
chpl foo.chpl

Execution command:
N/A - should fail at compilation, but does not

Associated Future Test(s):
test/functions/varargs/constRefVarargs.chpl #25902

Configuration Information

  • Output of chpl --version: 2.2.0 pre-release
  • Output of $CHPL_HOME/util/printchplenv --anonymize: any
  • Back-end compiler and version, e.g. gcc --version or clang --version: any
  • (For Cray systems only) Output of module list: N/A
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant