-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[clang-cl] access violation with an extern reference at runtime with clang-cl 20.1.0-rc2 using /std:c++latest #127572
Comments
It may be duplicate of #127475 |
@llvm/issue-subscribers-clang-codegen Author: Miuna (Mishura4)
```c++
// test.hpp
#include <vector> extern const std::vector<std::string>& vec_ref; void init();
// main.cpp
#include "test.hpp"
#include <iostream>
int main()
{
init();
for (auto& str : vec_ref)
{
std::cout << str << std::endl;
}
} Compile with Observations:
clang-cl was compiled with: set CXX=clang-cl
set CC=clang-cl
set VECTORIZE="-march=native -mtune=native"
cmake llvm/ -B build ^
-DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;lld;lldb" ^
-DLLVM_ENABLE_RUNTIMES="compiler-rt;libcxx" ^
-DLLVM_TARGETS_TO_BUILD=Native ^
-DLLVM_PARALLEL_COMPILE_JOBS=30 ^
-DLLVM_PARALLEL_LINK_JOBS=3 ^
-DLLVM_ENABLE_LLD=on ^
-DCLANG_DEFAULT_LINKER=lld ^
-DCMAKE_BUILD_TYPE=Release ^
-DCLANG_ENABLE_BOOTSTRAP=On ^
-DLLVM_HOST_TRIPLE=x86_64-pc-windows-msvc ^
-DLLVM_ENABLE_LTO=Thin ^
-DLLVM_ENABLE_EH=ON ^
-DLLVM_ENABLE_RTTI=ON ^
-DLLVM_ENABLE_LIBXML2=ON ^
-DCMAKE_CXX_STANDARD=20 ^
-DBOOTSTRAP_CMAKE_CXX_FLAGS=%VECTORIZE% ^
-DBOOTSTRAP_CMAKE_C_FLAGS=%VECTORIZE% ^
-DBOOTSTRAP_CMAKE_EXE_LINKER_FLAGS=%VECTORIZE% ^
-DRUNTIMES_x86_64-pc-windows-msvc_LLVM_ENABLE_EH=ON ^
-DRUNTIMES_x86_64-pc-windows-msvc_LLVM_ENABLE_RTTI=ON ^
-DRUNTIMES_x86_64-pc-windows-msvc_LLVM_ENABLE_LIBXML2=ON ^
-DCMAKE_MT=mt.exe ^
-G Ninja
ninja -C build (Issue also happens with |
Yep, looks very similar |
Fixed in 9010db1 |
@llvm/issue-subscribers-clang-frontend Author: Miuna (Mishura4)
```c++
// test.hpp
#include <vector> extern const std::vector<std::string>& vec_ref; void init();
// main.cpp
#include "test.hpp"
#include <iostream>
int main()
{
init();
for (auto& str : vec_ref)
{
std::cout << str << std::endl;
}
} Compile with Observations:
clang-cl was compiled with: set CXX=clang-cl
set CC=clang-cl
set VECTORIZE="-march=native -mtune=native"
cmake llvm/ -B build ^
-DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;lld;lldb" ^
-DLLVM_ENABLE_RUNTIMES="compiler-rt;libcxx" ^
-DLLVM_TARGETS_TO_BUILD=Native ^
-DLLVM_PARALLEL_COMPILE_JOBS=30 ^
-DLLVM_PARALLEL_LINK_JOBS=3 ^
-DLLVM_ENABLE_LLD=on ^
-DCLANG_DEFAULT_LINKER=lld ^
-DCMAKE_BUILD_TYPE=Release ^
-DCLANG_ENABLE_BOOTSTRAP=On ^
-DLLVM_HOST_TRIPLE=x86_64-pc-windows-msvc ^
-DLLVM_ENABLE_LTO=Thin ^
-DLLVM_ENABLE_EH=ON ^
-DLLVM_ENABLE_RTTI=ON ^
-DLLVM_ENABLE_LIBXML2=ON ^
-DCMAKE_CXX_STANDARD=20 ^
-DBOOTSTRAP_CMAKE_CXX_FLAGS=%VECTORIZE% ^
-DBOOTSTRAP_CMAKE_C_FLAGS=%VECTORIZE% ^
-DBOOTSTRAP_CMAKE_EXE_LINKER_FLAGS=%VECTORIZE% ^
-DRUNTIMES_x86_64-pc-windows-msvc_LLVM_ENABLE_EH=ON ^
-DRUNTIMES_x86_64-pc-windows-msvc_LLVM_ENABLE_RTTI=ON ^
-DRUNTIMES_x86_64-pc-windows-msvc_LLVM_ENABLE_LIBXML2=ON ^
-DCMAKE_MT=mt.exe ^
-G Ninja
ninja -C build (Issue also happens with |
Compile with
clang-cl test.cpp main.cpp /std:c++latest
. For some reason eithervec_ref
orimpl
seems to become corrupted and the for loop seems to read garbage data. In the project I initially encountered this, the program crashed with an access violation in std::vector::begin().Observations:
/std:c++latest
, the same code works without an issue on 20.1.0-rc2 with/std:c++20
/std:c++latest
.clang-cl was compiled with:
(Issue also happens with
-fuse-ld=link
)The text was updated successfully, but these errors were encountered: