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

'Illegal declaration of cycle' when struct member references sibling member size #4659

Open
SaculRennorb opened this issue Jan 5, 2025 · 0 comments

Comments

@SaculRennorb
Copy link

Context

Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.

    Odin:    dev-2024-12-nightly:cf53404
    OS:      Windows 10 Enterprise N (version: 20H2), build 19042.1466   
    CPU:     Intel(R) Core(TM) i5-8400 CPU @ 2.80GHz
    RAM:     65470 MiB
    Backend: LLVM 18.1.8

Expected Behavior

This

package main

A :: struct {
	a : struct { // Illegal declaration cycle of `a`
		t : u32
	},
	b : [1024 - size_of(a)]u8, 
}

main :: proc() {  }

should compile as the size of a should already be known by the time it is used, but it doesn't.

a : u32;

A :: struct {
	b : [1024 - size_of(a)]u8, 
}

main :: proc() {  }

does compile without issues.

Current Behavior

The compiler errors with

Error: Illegal declaration cycle of a
a : struct { // Illegal declaration cycle of a

Failure Information (for bugs)

Steps to Reproduce

Please provide detailed steps for reproducing the issue.

  1. copy the first snippet into a new file
  2. run odin build on the file
  3. error
@SaculRennorb SaculRennorb changed the title 'Illegal declaration of cycle' when outer struct references inner member size 'Illegal declaration of cycle' when struct member references sibling member size Jan 5, 2025
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