Questions tagged [compiler-bug]

For questions about (suspected) incorrect behavior of a compiler. Use with the appropriate language tag and, where applicable, with the tag for the compiler in question.

309 questions
1
vote
1 answer

Why is NVCC more strict with constexpr than non-constexpr host functions?

Consider the following code: constexpr __host__ void foo() { } __global__ void baz() { if constexpr(1==2) { foo(); } } this fails to compile with CUDA 11.3.1's NVCC. However, if I remove the constexpr - it does compile. How come? Is this a…
einpoklum
  • 118,144
  • 57
  • 340
  • 684
1
vote
1 answer

Why does "Add IDL Method" on an Interface add the method to the Module as well as to the CoClass?

This question is about using Visual Studio 2019 for building an out-of-process COM server using ATL. (I have done this before in Borland but this is my first time using MSVC). I created a project called MyObjectsProject with ATL Project wizard.…
M.M
  • 138,810
  • 21
  • 208
  • 365
1
vote
2 answers

Can someone explain hard ilogical bug on C use of #define UMAX (a, b) ((a) > (b) ? (a) : (b)) directive, that returns lower value, in 2 compilers

I'm trying to identify the reason of a bug that happens on a MUD c code base. Where the use of the #define UMAX(a, b) ((a) > (b) ? (a) : (b)) , is used to return the max of two values. It sometimes returns the lower value, and even debuging I…
1
vote
1 answer

Visual C++ compiler bug?

I've reduced my case as much as possible below. #include #include #include using namespace std; class Unused { private: vector> data; atomic counter; }; class Timer { private: …
1
vote
1 answer

GCC leaking its lambda implementation into the user's program?

How is it possible that the following code is successfully compiled by GCC version [6..10] ? int main(int argc, char *argv[]) { auto const answer = 42; auto lambda = [&answer] {}; auto *p = &(lambda.__answer); return p != &answer;…
Bulletmagnet
  • 5,665
  • 2
  • 26
  • 56
1
vote
1 answer

Error when erasing an object element of a vector when operator overloading is defined

In the simple example program below, I have a vector of objects t_cell which I initialize with 5 elements. I also have a test vector of integers. #include #include #include using namespace std; class t_cell { …
solalito
  • 1,189
  • 4
  • 19
  • 34
1
vote
0 answers

Possible c# compiler bug where static constructor is not called as expected

Given the trivial C# console application below, I would expect the output to be: NullCell = 1.23. Instead it outputs: NullCell = 0.0 This feels like a bug as C# commits to calling the static constructor on a class before an instance or a static…
Raymond Wilson
  • 217
  • 2
  • 6
1
vote
1 answer

Avoiding ambiguous parameters in templated Eigen functions with MSVS

I'm writing some funtions that are supposed to take Eigen::Array as an input. The Arrays are of constant size, but the size is a template parameter and should be deducted from the input. When compiling with MSVS, i have to supply the size to the…
Daniel Bauer
  • 478
  • 3
  • 16
1
vote
0 answers

Optimized GCC output for ARM A7 malfunctioning

Attention ARM assembly gurus! I have some code that surprisingly fails when optimized. I have it isolated in a simple unit test on my embedded device. The code is built for an ARM A7 embedded environment, using…
jws
  • 2,171
  • 19
  • 30
1
vote
1 answer

Inconsistent Accessibility of Nested object Declarations in Kotlin

Consider the following Kotlin code: object Domain { val name = "local" val location = object { val city = "Pittsburgh" val state = "Pennsylvania" } } While this definition is valid and compiles, the following line fails: val x =…
LBushkin
  • 129,300
  • 32
  • 216
  • 265
1
vote
0 answers

gcc and clang not willing to lazily initialize a partially-used struct

Consider the following code: __attribute__((noinline)) int foo1(int x, int y) { return x; } int bar1(int* a) { int b = foo1(a[5], a[10]); return b * b; } Even though foo1 is not inlined, a compiler can easily tell one of its parameters…
einpoklum
  • 118,144
  • 57
  • 340
  • 684
1
vote
3 answers

String interpolation: a bug in c# compiler?

string Test(bool @bool) => $"you're {@bool?"hired":"fired"} Have a nice day!"; The code above results in compilation error. But why? Notice that string test = $"this {"is"} working"; works.
Amad
  • 25
  • 9
1
vote
0 answers

Clang fails to initialize static const template member

In order to force the execution of a template method at program start one can initialize a static member with a static method. Then the method is run at program start for every instantiation of the template class: #include…
HenrikS
  • 402
  • 3
  • 13
1
vote
0 answers

Compiler bug in Visual studio?

The following compiles with the Microsoft C++ compiler (VS 15.5.6 --std=c++14) instead of producing the expected error. #include template class Foo { public: Foo(type x, std::string y) : x(x) , y(y) …
AndyMcoy
  • 179
  • 1
  • 3
  • 13
1
vote
1 answer

Visual C++ 2017 bug? Compiler optimizes away expression

The following piece of code has been causing me some issues, specifically the evaluation of diff: #include template class array2d { protected: T* arr; int w, h; public: array2d() : arr(nullptr), w(0), h(0) {} bool…
lightxbulb
  • 1,251
  • 12
  • 29