zig
                                
                                
                                
                                    zig copied to clipboard
                            
                            
                            
                        Sema: copy pointer alignment to union field pointers
Resolves: #15878
Hm, this isn't quite right for tagged unions in some cases. The current layout of tagged unions is such that the larger of the tag and payload comes first. This has a weird consequence: if we have an *align(128) U, then &ptr.field is align(128) only if the payload is larger than the tag (since then the payload comes first so inherits the alignment, even if it's larger than the payload's natural alignment). I don't think it's desirable to have the type of a field pointer depend on language semantics like this, so we have a few choices here:
- Make 
&u.fieldfor tagged unions cap the alignment at the union's natural alignment, regardless of whether it's actually more-aligned. This is probably the simplest option. - Change the backends so the payload comes first, regardless of its size. This would be more work, and might make tagged unions bigger in memory in some cases, but would have less surprising semantics at the language level.
 
This merge has been reverted in 43c98dc11567eeb38be041c7dad179c53156f3df while the large variety of random failures that occur with the build system on my local configuration in response to this change are investigated.
The previous revert has been unreverted in 2282c278850e29af81e463d55c81fa08855823f8 due to finally diagnosing the issue as being related to linux kernel 6.4.0 and not this PR.