31,807 questions
3 votes
1 answer
142 views
Conditional operator with a throwing branch in Visual C++ 2026
My program changed its behavior after updating Visual Studio to the latest version (2026). Simplifying it, I got the following minimal example, which contains a ternary operator with a throw in ...
4 votes
1 answer
174 views
MSVC 14.38.33130: Does std::atomic_ref::is_lock_free have a bug? It returns true for a 1024-byte struct
I am encountering suspicious behavior with std::atomic_ref::is_lock_free() in Microsoft Visual Studio's C++ compiler (MSVC version 14.38.33130). The method returns true for a very large structure (...
0 votes
0 answers
133 views
C++ Unicode Problems/Questions
I wrote two versions of a little program in C++ with MSVC on Windows 11: First one: #include <iostream> #include <Windows.h> int main() { SetConsoleOutputCP(CP_UTF8); std::cout &...
0 votes
1 answer
179 views
Is it valid to explicitly call a constructor, like S::S{}?
Here's the code: struct S{}; int main() { S::S{}; return 0; } When using GCC and Clang, it will fail with a clear error output: qualified reference to 'S' is a constructor name rather than a ...
Advice
1 vote
7 replies
179 views
How does Microsofts std::lib implementation perform debug iterator checks?
In the question Why does Microsoft's implementation of std::string require 40 bytes on the stack? the observation is made, that a std::string requires 8 additional bytes in Debug mode. After ...
0 votes
1 answer
57 views
Using a derived edit box control to process keystrokes ahead of CEdit control in MFC
In a modeless dialog box in MFC, I want to create an edit box control, derived from CEdit, that will allow me to intercept keystrokes (in particular the CR) and process it differently from the default ...
0 votes
1 answer
60 views
In subclassing an edit box using SetWindowLongPtrA() to pass a function address, I get an "incompatable type" error
I'm trying to subclass an edit box in a dialog in VS C++ 2022. I want to intercept any key presses in a particular edit box to do further processing. Here's my code. The 4th line confuses me because I ...
14 votes
1 answer
372 views
Are pointers to pure virtual member functions of local classes allowed?
Consider the following snippet: int main() { struct Local { virtual void foo() = 0; }; void (Local::* ptr)() = &Local::foo; } When compiling with C++20, GCC 13.3.0 and Clang 18.1.3 ...
0 votes
1 answer
115 views
Does integer zero division always raise exception on 64-bit Arm on Windows?
When I perform integer division by zero on Windows 11 on Arm64, it raises a SEH exception. That is rather surprising, considering Arm by default does not trap zero division. My question is: does the ...
12 votes
1 answer
734 views
How can I set up Thread-Local Storage (TLS) callbacks on Windows without CRT?
I'm trying to register a Thread-Local Storage (TLS) callback in a Windows application without using the C runtime (CRT). Compiler: MSVC 14.44.35207 (Visual Studio 2022) Target: x64 OS: Windows 11 I ...
2 votes
1 answer
183 views
Is it possible to call x86 `idiv r/m8` from MSVC2022 using C++ directly?
I am trying to call idiv r/m8 using MSVC2022's current Microsoft Visual C++ Compiler 17.4.33403.182 and C++. Using the most straightforward approach: struct cdiv_t { // char std::int8_t quot; ...
2 votes
2 answers
148 views
Why would MSVC 2022 create two idiv calls for one std::div without any optimizations?
Using CMAKE_BUILD_TYPE="Debug" my MSVC 2022 [17.4.33403.182] produced one idiv call for the quotient and an identical idiv call for the remainder. The code was simply [see here for the ...
0 votes
0 answers
86 views
Loading a resource DLL build for a different architecture to only assess resources
I'm programming a MFC application that should be internationalized. Currently I'm providing separate language DLLs per architecture (ARM64, x86, x64), but I'm unsure whether this is really necessary. ...
0 votes
0 answers
89 views
Use resource DLL loaded using LoadLibraryEx(..., LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE) with AfxSetResourceHandle
I'm programming a MFC application that should be internationalized. Currently I'm providing separate language DLLs per architecture (ARM64, x86, x64), but recently I came accross ::LoadLibraryEx(...
0 votes
0 answers
109 views
Win32 api Edit Control doesn't respond to mouse clicks in child window
I'm having an issue with WinAPI Edit controls in a child window - they don't respond to mouse clicks, but work fine when placed in the main window. Other controls like buttons work normally in both ...