[Issue 24867] Wrong deprecation warning of @system variable usage under CTFE

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Nov 19 21:08:19 UTC 2024


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

--- Comment #9 from kinke <kinke at gmx.net> ---
(In reply to Luís Ferreira from comment #7)
> > No example you gave here justifies the outer `align(1)`
> 
> It does. Considering our tracing system:
> 
> ```
> align(1) struct TracesMetadata {
> align(1): 
>     const char* name;
>     int b = 2;
> }
> 
> @section(".traces.metadata") @assumeUsed
> static immutable Bar bar1 = Bar("foo1");
> @section(".traces.metadata") @assumeUsed
> static immutable Bar bar2 = Bar("foo2");
> ```
> 
> We need both alignment specifiers in order for the section to be fully
> packed across two of those constants.

If that's really the case (with which compilers? and I assume `Bar` is
`TracesMetadata` in your snippet), then that's a bug. The default aggregate
alignment is the max of its members, so the common `align(1):` for all fields
makes the aggregate automatically 1-aligned, and the outer `align(1)` type
alignment *override* redundant [and IMO very bad practice].

All off-topic, I know, it's just that this deprecation can currently be worked
around when dropping the type-align-override.

--


More information about the Digitalmars-d-bugs mailing list