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
0
votes
0 answers

Did MSVC ever correctly support bit-fields based on enums?

When I first posted this related question I thought I had hit some weird edge-case that possibly included undefined behavior. However, if you read the most recent update there, you will see that a much simpler example also doesn't work. Test the…
0
votes
1 answer

Divide by zero error from Colt OpenLongObjectHashMap

I saw this exception from Colt OpenLongObjectHashMap: java.lang.ArithmeticException: divide by zero at cern.colt.map.OpenLongObjectHashMap.indexOfKey(Unknown Source) at cern.colt.map.OpenLongObjectHashMap.get(Unknown Source) It's…
rghome
  • 8,529
  • 8
  • 43
  • 62
0
votes
2 answers

How can I work around this parameter expansion bug in GCC without upgrading to 8.x?

Consider the following code: #include #include #include #include #include template void foo() { std::cout << N << "(" << ") "; } template<> void foo<2>() { std::cout << "TWO (" << ")…
einpoklum
  • 118,144
  • 57
  • 340
  • 684
0
votes
0 answers

Compiler difference between GCC for c++11 and USACO compiler

For the USACO training gateway exercise humble numbers, I have a solution that works for the first 4 test cases, but then for test case 5 which has been supplied below to circumvent the need for input files, my program gets the correct answer…
Yadeses
  • 195
  • 1
  • 8
0
votes
0 answers

Strange compile error related to template bracket interpreted as operator ">"

I've got a strange compile error with intel compiler on linux. So I did some tests with Compiler Explorer. This code compiles fine on several compilers: enum class Enum {a, b}; template struct Base { template void F(int)…
ThreeStarProgrammer57
  • 2,906
  • 2
  • 16
  • 24
0
votes
1 answer

Swift closure compiling failed with expression too complex

public static func easeOutQuint(_ t: Float, _ b: Float, _ c: Float, _ d: Float = 1.0) -> Float { return { return c * ($0 * $0 * $0 * $0 * $0 + 1.0) + b }(t / d - 1.0) } I'm not familiar with closure, so I can not fix it by myself,…
Henson Fang
  • 1,177
  • 7
  • 30
0
votes
0 answers

VC++ 64 Bit Stack Frame Layout Bug

I want to know how MSVC 2010 generates code for volatile local variables and have done a test. This simple test function uses a volatile local variable: int proc1(int a, int b) { int volatile volvar=0; int c=a; if (b>a) c=0; …
JavaMan
  • 4,954
  • 4
  • 41
  • 69
0
votes
1 answer

VC++ Bug with Decltype and Universal Reference or Undefined Behavior?

I have this code: #include #include using namespace std; template T f2(T&&t) { return t; } int rr(int i) { return 40*i; } int main() { cout << is_function<…
JavaMan
  • 4,954
  • 4
  • 41
  • 69
0
votes
1 answer

unable to find a register to spill in class 'POINTER_REGS' (maybe compiler bug)

The issue is that this code will not compile with avr-g++ compiler. It produces the error in the headline. When you comment out either line 15 or 16, it will compile. If you remove ''colourArray'' or ''blackArray'' from the right side of line 15 and…
Zinoex
  • 512
  • 2
  • 8
  • 22
0
votes
1 answer

G++ and clang++ incompatibility with standard library when building shared libraries?

If I have a file clang.cpp containing: #include void myfunc() { std::map mymap; const int x = 20; myfoo[x] = 42; } and main.cpp containing: void myfunc(); int main() { myfunc(); } compiling clang++ -g clang.cpp -shared…
Darioush
  • 565
  • 3
  • 14
0
votes
1 answer

Why might an assignment in Swift not happen?

In the following Swift code, for some types T:HasDefaultValues, the assignment in init(variableValue: T) does not happen and the member variable takes the value of T.defaultValue: protocol HasDefaultValues : Equatable { static var defaultValue:…
Chris
  • 941
  • 9
  • 18
0
votes
2 answers

strange double free corruption (GCC 4.9.2, Clang3.6 on Ubuntu Vivid)

The following MWE gives a strange address sanitizer report: #include class A { public: A(){} ~A(){} }; class B{ public: B(){ m_grid = new A(); } ~B(){ delete m_grid;} A * m_grid = nullptr; …
Gabriel
  • 8,990
  • 6
  • 57
  • 101
0
votes
1 answer

Why this C++ program behave differently on different compilers?

I was reading this. That question contains following program. #include #include #include int main() { using namespace std; string myString = "Press ENTER to quit program!"; cout << "Come up and C++ me some…
Destructor
  • 14,123
  • 11
  • 61
  • 126
0
votes
1 answer

Swift: 'Int' is not convertible to 'ObjCBool'

In my code I have a lazy var: lazy var myService = { return JSObjection.defaultInjector().getObject(MyService) as? MyService }() In the same file I try to call a function of myService: func foo() { …
Bastian
  • 4,638
  • 6
  • 36
  • 55
0
votes
1 answer

Swift EXC_BAD_INSTRUCTION on call to typealias / typed / defined closure w/o compiler error or warning

Given a struct, a class, and typed closure: struct Vector3d { var X:Double var Y:Double var Z:Double } class Sprite { var mass: Double = 0.0 init(mass: Double) { self.mass = mass } } typealias ForceComputation = …
Joshcodes
  • 8,513
  • 5
  • 40
  • 47
1 2 3
20
21