Rust-GCC / Rust-GCC/gccrs

gccrs does not check if something is assignable

Open
#3,287 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

diagnostic
Dominant language
C++
Stars
2.9k
Forks
231
Avg merge
20h 2m
Merged PRs (30d)
66

Description

Summary

gccrs does not check if something is assignable, and gccrs accepts many un-assignable expressions.

Reproducer

I tried this code:

fn main() -> i32 {
    let mut x = 42;
    x + 1 = 2;

    x
}
Does the code make use of any (1.49) nightly feature ?
  • Nightly
Godbolt link

No response

Actual behavior

The current behavior is that gccrs accepts this kind of semantically invalid code and even successfully generates machine code for them (in this case, gccrs generates code to make the function return 42).

Expected behavior

I expected to see an error thrown like rustc does:

error[E0070]: invalid left-hand side of assignment
 --> test1.rs:3:11
  |
3 |     x + 1 = 2;
  |     ----- ^
  |     |
  |     cannot assign to this expression
GCC Version

fa93e280ed1c11d9775cb9c3211e13853d39c51c

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by compiling the reproducer with gccrs and compare its result with rustc's E0070 diagnostic for x + 1 = 2. Trace the assignment semantic-checking entry point responsible for accepting the expression; done means gccrs rejects unassignable left-hand sides and reports an appropriate error without generating machine code.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.