compiler-bug Questions
1
Anyone knows what kind of UB is this? The following code deadlocks on jthread destruction when built with MSVC 19.29.30148, sometimes it deadlocks after std::cout and sometimes before.
This is some...
Ozell asked 18/9, 2023 at 10:31
2
Solved
TL;DR: see compilers disagree on code by Godbolt link: https://godbolt.org/z/f7G6PTEsh
Should std::variant be nothrow destructible when its alternative has potentially throwing destructor? Clang an...
Discipline asked 10/6, 2024 at 13:56
1
For some reason GCC regards variable a as an rvalue within the initialization of variable b (of which the expression is of type int&). And, as a result, rejects the code as it's not able to bin...
Oskar asked 13/5, 2024 at 23:58
2
Solved
Context
The standard says (C17, 6.5.3.4 ¶2):
The sizeof operator yields the size (in bytes) of its operand, which may be an expression or the parenthesized name of a type. The size is determined f...
Trifocal asked 6/4, 2024 at 9:30
1
Solved
The code that fails for clang (while gcc seems okey with it)
int arr[] { 111, 222, 333};
ranges::subrange(
ranges::begin(arr),ranges::end(arr) );
It looks like clang claim gcc's subrange do not...
Feldman asked 11/10, 2020 at 5:17
1
I wrote the following code that has two lambdas. One of them explicitly captures i while the other doesn't. Note i is constexpr so we don't need to capture it explicitly.
My question is why func(la...
Maintop asked 2/3, 2024 at 13:30
1
Solved
I was running a C++ program that provides a service, and noticed that it was taking 100% of a CPU even when serving no requests. I narrowed the problem down to a while loop which calls std::sleep_f...
Alligator asked 10/1, 2024 at 16:12
2
Solved
I recently learnt that we can have more than one default constructor in a class. Then I wrote the following program that compiles with msvc but both clang and gcc fails to compile this.
struct A
{
...
Stereotypy asked 9/1, 2024 at 18:4
1
Solved
Consider this code:
#include <type_traits>
template <typename T>
struct wrapper {
T& ref;
constexpr wrapper(T& ref) : ref(ref) {}
};
// Trait that checks whether a type is o...
Hilaire asked 6/1, 2024 at 7:2
1
Solved
I've defined two versions of a function template called compare:
#include <cstring>
using namespace std;
// fist version
template <size_t N, size_t M>
int compare(const char (&a)[...
Angell asked 22/12, 2023 at 3:19
1
Solved
While answering a question here, I made the following example:
#include <stdio.h>
#include <math.h>
int main (void)
{
float_t a = -248.75;
printf("%f\n", a);
unsigned ch...
Electrochemistry asked 19/10, 2023 at 13:29
2
Solved
Consider the following code:
#include <iostream>
int main() {
long long x = 123456789123456789;
std::cout << std::fixed;
auto y = static_cast<double>(x); // (1)
std::cout <...
Relieve asked 14/10, 2023 at 21:5
3
Solved
I stumbled across a situation where a library sorts a container (e.g. std::vector<T>) with a user-provided comparison object. For one particular case, the user actually doesn't want to sort t...
Aurar asked 3/10, 2023 at 17:7
1
Solved
Considering the following code example, I would expect to have to use the template keyword here to guide the compiler to treat variable v as a template. However, MSVC rejects the use of the templat...
Sexology asked 20/9, 2023 at 15:35
8
Solved
Code (spring-web 5.1.2)
public static void main(String[] args) {
RestTemplate restTemplate = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
headers.set(HttpHeaders.AUTHORIZATION,...
Nakasuji asked 19/2, 2019 at 21:33
1
While experimenting with compile-time string manipulation, I've encountered a strange phenomenon:
#include <bit>
constexpr char str[4] = "abc";
// error: constexpr variable 'x' mu...
Forseti asked 9/5, 2021 at 0:32
1
Solved
The following C++ code gives an error with GCC (e.g. 13.1, see godbolt.org) where the compiler seems to confuse the set member function template with std::set:
#include <set>
using namespace ...
Engrossment asked 26/7, 2023 at 0:49
1
Solved
This code compiles
template<typename T>
struct A {
struct Inner {} inner;
void foo(Inner in);
};
template<typename T>
void A<T>::foo(typename A<T>::Inner in) {
}
int ma...
Stenotype asked 6/6, 2023 at 16:20
0
Of course, C# supports unidimensional and multidimensional arrays, and supports arrays of arrays. Famously, if, in an array of arrays, the inner array type has a different rank (dimension count) th...
Awake asked 12/5, 2023 at 10:18
1
The code:
#define OPPOSITE(c) (*((typeof(x) *)&(x)))
int foo(volatile int x)
{
OPPOSITE(x) = OPPOSITE(x) + OPPOSITE(x);
return x;
}
int bar(volatile int x)
{
OPPOSITE(x) = OPPOSITE(x) + OP...
Gottschalk asked 9/2, 2023 at 9:20
0
I am almost sure that the following is a bug of Visual Studio compiler, but it is so hard to believe that I decided to double check here:
struct A {
constexpr virtual int f() { return 0; }
};
str...
Derayne asked 10/2, 2023 at 18:24
1
Solved
I recently came across a weird double-free bug in a program when capturing a shared_ptr in a lambda. I was able to reduce it this the following minimal example:
#include <memory>
#include <...
Gertrudgertruda asked 15/10, 2022 at 14:12
1
Solved
Background
While debugging a problem in a numerical library, I was able to pinpoint the first place where the numbers started to become incorrect. However, the C++ code itself seemed correct. So I ...
Unformed asked 23/1, 2022 at 15:35
2
Solved
Consider the following code (Compiler Explorer link), compiled under gcc and clang with -O3 optimization:
#include <arm_neon.h>
void bug(int8_t *out, const int8_t *in) {
for (int i = 0; i &...
Feinberg asked 7/10, 2021 at 22:30
2
The question mark in the title is only there because I'm very reluctant to call anything a compiler bug, but in this case, I'd be surprised if anyone could explain this behavior in any other way.
T...
Riffe asked 27/11, 2020 at 17:59
1 Next >
© 2022 - 2025 — McMap. All rights reserved.