https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125015
Bug ID: 125015
Summary: alias attribute does not diagnose mismatched
type/size/alignment as documented
Product: gcc
Version: 15.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: kartik7ohlan at gmail dot com
Target Milestone: ---
The GCC documentation for the alias attribute states:
“Except for top-level qualifiers the alias target must have the same type as
the alias. For variables, it must also have the same size and alignment.”
However, GCC accepts programs where the alias declaration has a different type,
size, and alignment than the aliased target without issuing any diagnostic
[gcc](https://gcc.gnu.org/onlinedocs/gcc/Common-Attributes.html#index-alias)
Reproducer Code:
#include<iostream>
#include<cstdint>
static int global = 10000; // global
extern int y __attribute__((alias("_ZL6global"))); // PASS
extern char ch __attribute__((alias("_ZL6global"))); // type mismatch
extern double d __attribute__((alias("_ZL6global"))); // type mismatch
extern int alias_var __attribute__((alias("_ZL6global")))
__attribute__((aligned(16))); // misalignment