-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Open
Labels
Description
Description / Steps to reproduce the issue
Minimal reproducible example:
#include <iostream>
int main()
{
std::cout << "------------\n";
constexpr double number = 10.281423568725586;
const int saveFloatNumberPrecision = 6;
const int charBufferLen = 64;
char charBuffer[charBufferLen];
for (int i = 0; i < 1e7; ++i) {
snprintf(charBuffer, charBufferLen, "%.*f", saveFloatNumberPrecision, number);
}
std::cout <<charBuffer << " " << "------------\n";
return 0;
}
Build (qmake-generated Makefile.Debug):
mingw32-make -f Makefile.Debug
g++ -c -g -std=gnu++1z -Wall -Wextra -fexceptions -mthreads \
-march=nocona -msahf -mtune=generic -Wa,-mbig-obj \
-DUNICODE -D_UNICODE -DWIN32 -DMINGW_HAS_SECURE_API=1 -DQT_QML_DEBUG \
-I<project> -I<build> -I<qt-mkspecs> \
-o debug/main.o main.cpp
g++ -Wl,-subsystem,console -mthreads -o debug/untitled.exe debug/main.o
gcc version 14.2.0 (Rev3, Built by MSYS2 project)
QMake version 3.1
Using Qt version 5.15.16 in C:/msys64/mingw64/lib
Crash dump:
untitled.exe.51520.dmp
Repro project(sources + build):
untitled.zip
Expected behavior
Program should run to completion, print the separators (and the formatted number), and exit with code 0.
No crash should happen when calling snprintf in a tight loop.
Actual behavior
The program crashes during the loop with SIGILL (illegal instruction) on Windows when built with MSYS2 MinGW-w64.
Notes:
- If I comment out the
snprintf(...)call, the program does not crash. - The same code compiled with MSVC runs fine!
Verification
- I have verified that my MSYS2 is up-to-date before submitting the report (see https://www.msys2.org/docs/updating/)
Windows Version
Windows 11 24H2 (build 26100)
MINGW environments affected
- MINGW64
- MINGW32
- UCRT64
- CLANG64
- CLANGARM64
Are you willing to submit a PR?
Possibly, with guidance
Reactions are currently unavailable