374 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
22
votes
1
answer
1k
views
Is GCC right when it accepts a class template having a member with a wrong default member initializer?
GCC 15.2 (and many older versions) accepts the following code, while Clang 21.1 (and many older versions) don't:
struct Wrapper
{
explicit Wrapper(int) {}
};
template <int N = 0>
struct ...
5
votes
1
answer
132
views
Can you observe whether _Atomic expands to an alias template or class template?
[stdatomics.h.syn] specifies the following:
template<class T>
using std-atomic = std::atomic<T>; // exposition only
#define _Atomic(T) std-atomic<T>
libc++ and libstdc++ ...
4
votes
1
answer
258
views
c++ C1001 when a class is declared
I'm having a C1001 issue (internal compiler error) when a class is declared and not when it is commented. Compiling the following code with
cl /std:c++latest /O2 /Oi /fp:fast /Gy /GL /Gw /EHsc /MD /...
7
votes
1
answer
335
views
Does GCC optimize array access with __int128 indexes incorrectly?
When compiling the following code using GCC 9.3.0 with O2 optimization enabled and running it on Ubuntu 20.04 LTS, x86_64 architecture, unexpected output occurs.
#include <algorithm>
#include &...
1
vote
1
answer
211
views
Function can't be called after std::unreachable if object constructed on stack?
Normally, I can place function calls after std::unreachable, and it has no effect. This works on MSVC, Clang, and GCC, except with GCC there is an extra detail that makes it fail compilation:
#include ...
2
votes
0
answers
105
views
MSVC bug? – `std::type_info::name()` fails when non-type template parameter has type `unsigned long long`
I have long thought it odd that MSVC uses __int64 as the name for type long long in all of its diagnostic messages.
// MSVC outputs "__int64"
std::cout << typeid(long long).name();
It ...
2
votes
1
answer
96
views
C++23 MSVC build in GitHub CI fails for inexplicable reasons
I am trying to build some C++ code in the GitHub CI.
This works for GCC and Clang, but compilation with MSVC fails in very weird ways.
The very first error is found at:
template <bool constant, ...
0
votes
1
answer
67
views
Inconsistent reporting of obsolete member usages
Consider this class:
public class Number
{
[System.Obsolete()] public string ToExactString() => "";
[System.Obsolete()] public override string ToString() => "&...
1
vote
0
answers
95
views
False positives with Clang CFI sanitizer and array of functions
This is a follow-up related to Inconsistent false positives with Clang CFI sanitizer and function pointers, but it is for a separate issue
Issue
Background
I have an array of structs which store ...
0
votes
0
answers
64
views
Understanding `omp_orig` in a custom OpenMP reduction
I've encountered a bug when using Clang[1] with libomp[2] whereby using omp_priv = omp_orig in the initializer of a custom OpenMP reduction silently gives erroneous output. For example:
/* file.cpp */
...
6
votes
1
answer
107
views
Do template parameter packs affect overload resolution?
Look at this code (godbolt):
template <typename ...T>
void func(const char *it, T &&...t) {}
template <typename A, typename B>
void func(A &&a, B &&b) {}
int main(...
1
vote
0
answers
122
views
Inconsistent false positives with Clang CFI sanitizer and function pointers
Issue
Background
I have an array of structs which store function pointers, which I loop over and call (my real code is more complex than the sample given). To ensure correct behaviour, I enabled CFI ...
2
votes
1
answer
314
views
Incorrect `cast-align` warnings on GCC and Clang even with `__attribute__((aligned))`
Background
I have a struct with a flexible array member, which I am using to store arbitrarily-sized data inline (for a generic linked list for any element type), and I can simply cast data to T* to ...
0
votes
0
answers
65
views
clang 19.1.0 rejects nested lambda with templates
The following code generates an error on clang 19.1.0, but passes on older versions, gcc and msvc (live example).
template <typename>
void func() {
(void)[]<typename>() consteval {
...
4
votes
2
answers
205
views
Accesssing fields from a struct[] returns a very large integer
I have a C++ program that creates a two-element array of structs, then outputs the a field from one of the structs based on user input.
When user the inputs 1 to the program, it should print 0 since ...