Thread overview | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
March 07, 2019 [Issue 19605] enum X: "Error: enum X is forward referenced when looking for sizeof" | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19605 Tiberiu Lepadatu <tiberiulepadatu14@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |tiberiulepadatu14@gmail.com --- Comment #1 from Tiberiu Lepadatu <tiberiulepadatu14@gmail.com> --- (In reply to elpenguino+D from comment #0) > Very easy to reproduce: > ``` > enum X; > static assert(X.sizeof == 0); > ``` > > Note that I'm not exactly sure what the size of this should be. My guess was 0, but DMD 2.064 seems to manage to evaluate it to 4 despite still issuing the same It is 4 because it is the same as sizeof int. I will look into the error. [1] https://dlang.org/spec/enum.html -- |
March 17, 2019 [Issue 19605] invalid forward reference error when getting the `.sizeof` if an opaque enum | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19605 Basile-z <b2.temp@gmx.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |rejects-valid CC| |b2.temp@gmx.com Summary|enum X: "Error: enum X is |invalid forward reference |forward referenced when |error when getting the |looking for sizeof" |`.sizeof` if an opaque enum -- |
March 17, 2019 [Issue 19605] invalid forward reference error when getting the `.sizeof` of an opaque enum | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19605 Basile-z <b2.temp@gmx.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|invalid forward reference |invalid forward reference |error when getting the |error when getting the |`.sizeof` if an opaque enum |`.sizeof` of an opaque enum -- |
March 17, 2019 [Issue 19605] invalid forward reference error when getting the `.sizeof` of an opaque enum | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19605 Dlang Bot <dlang-bot@dlang.rocks> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |pull --- Comment #2 from Dlang Bot <dlang-bot@dlang.rocks> --- @Basile-z created dlang/dmd pull request #9460 "fix issue 19605 - invalid forward reference error when getting the `sizeof` of an opaque enum" fixing this issue: - fix issue 19605 - invalid forward reference error when getting the `.sizeof` of an opaque enum https://github.com/dlang/dmd/pull/9460 -- |
March 17, 2019 [Issue 19605] invalid forward reference error when getting the `.sizeof` of an opaque enum | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19605 --- Comment #3 from Basile-z <b2.temp@gmx.com> --- This one might be invalid actually. The implementation of the fix is problematic at least. -- |
March 17, 2019 [Issue 19605] invalid forward reference error when getting the `.sizeof` of an opaque enum | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19605 Basile-z <b2.temp@gmx.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords|pull, rejects-valid | -- |
March 21, 2020 [Issue 19605] invalid forward reference error when getting the `.sizeof` of an opaque enum | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19605 Basile-z <b2.temp@gmx.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC|b2.temp@gmx.com | -- |
December 17, 2022 [Issue 19605] invalid forward reference error when getting the `.sizeof` of an opaque enum | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19605 Iain Buclaw <ibuclaw@gdcproject.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Priority|P1 |P3 -- |
April 25, 2023 [Issue 19605] invalid forward reference error when getting the `.sizeof` of an opaque enum | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19605 RazvanN <razvan.nitu1305@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |razvan.nitu1305@gmail.com --- Comment #4 from RazvanN <razvan.nitu1305@gmail.com> --- sizeof is defined as being the size in bytes of an expression. It does not mean "the amount of bytes required for a variable to be stored in memory at program runtime". In this case, the compiler correctly reports that it uses 4 bytes to store the enumeration, even though it is empty. I guess this could be improved, however, that would make the code uglier. This way the compiler code treats empty enums and non-empty enums the same. The cost is that you may use some extra bytes at compile time. My take on this is that this is an invalid bug report, however, I am open to other perspectives. -- |
April 25, 2023 [Issue 19605] invalid forward reference error when getting the `.sizeof` of an opaque enum | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19605 Basile-z <b2.temp@gmx.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |b2.temp@gmx.com Resolution|--- |WORKSFORME --- Comment #5 from Basile-z <b2.temp@gmx.com> --- The spurious error is gone anyway. -- |
Copyright © 1999-2021 by the D Language Foundation