You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用AddressSanitizer时alignas属性被忽略——是否为GCC Bug?

GCC AddressSanitizer下栈变量对齐问题是否属于Bug?

当使用AddressSanitizer编译标志-fsanitize=address时,GCC的代码生成器似乎未按指定对齐值对齐栈变量。在x86_64 GNU/Linux平台上,使用g++ 13.1.1 20230429编译以下代码会触发断言失败;不添加该编译标志则无此问题。而相同架构下使用clang 15.0.7并添加该标志则不会出现此问题。请问这是否属于GCC的Bug?

#include <cassert>
#include <cstdint>

int main() {
    alignas(64) char c;
    auto addr = reinterpret_cast<uintptr_t>(&c);
    assert(addr % 64 == 0);
}

内容的提问来源于stack exchange,提问作者clang-enjoyer

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.21 22:22:35