llvm / llvm/llvm-project

Diagnose when an explicit alignment is weakened by other features

Open
#196,578 2 comments 0 reactions 0 assignees View on GitHub
clang:diagnostics clang:frontend
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

This was split off from a comment in #58638:

> We might want to open another somewhat similar issue to diagnose when `alignas` is weakened by something else:
> ```cpp
> #pragma pack(2)
> struct D2 {
> char m1;
> alignas(8) int m4;
> };
>
> static_assert(alignof(D2) == 2); // Clang and GCC accept, MSVC and EDG reject
> ```

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the provided C++ snippet and comparing how Clang handles alignas with #pragma pack against the behavior noted for GCC, MSVC, and EDG. Trace the compiler path responsible for alignment diagnostics; done means an explicit alignment weakened by another feature is diagnosed consistently, with a regression test for this case.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.