Rust-GCC / Rust-GCC/gccrs

Assigning structs to variables

Open
#3,104 15 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug codegen
Dominant language
C++
Stars
2.9k
Forks
231
Avg merge
19h 55m
Merged PRs (30d)
67

Description

Summary

gccrs lets you assign structs to variables, when rustc emits "expected value, found struct ..."

Reproducer

I tried this code:

struct A {
    a: u32,
}

fn main() {
    let a = A {a: 4};
    let b = A;
    a.a = 2;
}
Does the code make use of any (1.49) nightly feature ?
  • Nightly
Godbolt link

No response

Actual behavior

The current behavior is...

The code compiles.

Expected behavior

I expected to see...

error[E0423]: expected value, found struct `A`
 --> main.rs:7:13
  |
1 | / struct A {
2 | |     a: u32,
3 | | }
  | |_- `A` defined here
...
7 |       let b = A;
GCC Version

commit-hash: c83b22a6932240194879ea7d9e783a4c0daf1b79

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 provided Rust reproducer with gccrs at commit c83b22a6932240194879ea7d9e783a4c0daf1b79 and compare the result with rustc's expected E0423 diagnostic. Done means gccrs rejects let b = A; as an invalid value while continuing to accept the valid struct construction.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.