[Issue 19605] invalid forward reference error when getting the `.sizeof` of an opaque enum

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Apr 25 09:53:07 UTC 2023


https://issues.dlang.org/show_bug.cgi?id=19605

RazvanN <razvan.nitu1305 at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |razvan.nitu1305 at gmail.com

--- Comment #4 from RazvanN <razvan.nitu1305 at 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.

--


More information about the Digitalmars-d-bugs mailing list