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.
Questions tagged [compiler-bug]
309 questions
1
vote
1 answer
Template template and CRTP: compiler bugs, and GCC and clang do not agree
Consider the following code, in C++11, tested with g++-6, g++-7, clang++-3.8 and clang++-4.0
// Preamble
#include
// Base 0
template class Derived>
struct base0 {
void operator=(int) {std::cout <<…

Vincent
- 57,703
- 61
- 205
- 388
1
vote
2 answers
ambigous struct definition in different modules
I have a large C++11 project with MS Visual Studio 2015, that defines in two modules (= compilation units, cpp-files) two structs with same name but different content. Since the stucts are only defined and used within the modules and not exported…

Stefan
- 83
- 5
1
vote
2 answers
Is there a difference between unary - and n -
I am fairly certain that subtracting one uint8_t from another should result in another unsigned number, but some of my results are confusing me.
uint8_t a = 2;
uint8_t b = 1;
uint8_t c = -a;
long d = b - a;
long e = b + c;
When I obtain…

DarthRubik
- 3,927
- 1
- 18
- 54
1
vote
1 answer
msvc visual c++ incorrect formation of bound member function expression from static member function
Consider the following code:
#include
struct A {
template = 0>
static void fun() {}
templatesizeof(int)), int> = 0>
…

FaulerHase
- 299
- 2
- 8
1
vote
1 answer
msvc visual c++ silent incorrect code generation when constexpr initializing struct within union
Consider the following snippet trimmed down to illustrate the problem:
#include
struct A {
union {
struct { int a0, a1; } aa;
int bb[2];
};
#if 1 //bug
constexpr A(int a0, int a1) : aa{a0, a1} {}
#else //OK
…

FaulerHase
- 299
- 2
- 8
1
vote
1 answer
Is it an Rvalue or Lvalue After a Cast
The code here test for lvalue or rvalue after a type cast:
#include
template
T const f1(T const &t) {
printf("T const \n");
return t;
}
template
T f1(T &t) {
printf("T\n");
return t;
}
struct KK {
…

JavaMan
- 4,954
- 4
- 41
- 69
1
vote
0 answers
Argument-Dependent Lookup Issue when Casting with Decltype or compiler Bug?
When using Argument-Dependent Lookup in VC++2010, I casted the argument using decltype() and encountered some weird results:
template
struct Type {
typedef T type;
};
namespace NSC {
typedef enum {
mon
} DOW;
void…

JavaMan
- 4,954
- 4
- 41
- 69
1
vote
0 answers
Is Declaring a Meta-Class-Type for a Templatized Method an Error?
I think I have found a bug in gcc, but I'd like confirmation:
struct Foo {
void good(int);
template
void bad(T);
};
All of the following work fine:
enable_if_t, void>…

Jonathan Mee
- 37,899
- 23
- 129
- 288
1
vote
1 answer
valgrind errors on build with inlining made by g++5 - bug in valgrind or g++5?
The exact versions of g++ and valgrind:
g++-5 (Ubuntu 5.2.1-23ubuntu1~12.04) 5.2.1 20151031
valgrind-3.7.0
I didn't dive into which flag exactly does this…

onqtam
- 4,356
- 2
- 28
- 50
1
vote
1 answer
Ambiguity in constructor overload because of std::function
I want to make two overloads of the constructor of some class as follow:
foo(int, std::function);
foo(int, std::function)>);
When calling it, I got ambiguity problem. Why?
foo…

Humam Helfawi
- 19,566
- 15
- 85
- 160
1
vote
1 answer
Is a function call expression with a single non-type template parameter argument type-dependent?
Both clang 3.6 and gcc 5.0 require typename in the following example:
template
struct B
{
typedef int Type;
};
void f(int);
template
struct A
{
typedef typename B::Type Type;
};
This is covered by the…

willj
- 2,991
- 12
- 24
1
vote
1 answer
Compiler error or correct behavior for static const member variable, variadic templates, and &&?
I have noticed a strange behavior when trying to compile the code included below. I have 4 files as follows
createshared.h:
#ifndef CREATESHARED_H_
#define CREATESHARED_H_
#include
#include
#ifdef USE_REFREF
template

ilektron
- 390
- 3
- 15
1
vote
1 answer
Why does a record constructor misbehave in inline functions?
In the following code the record constructor does something strange.
It works OK in all instances, except in the line marked below:
program Project9;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils,
System.Generics.Collections;
type
…

Johan
- 74,508
- 24
- 191
- 319
1
vote
0 answers
Raw C++11 strings in macro on VS2013
It seems there is a bug in Visual Studio 2013 compiler concerning the support of C++11 raw strings.
The new raw strings in C++11 look for example like R"(\s(\d+))"; they are very handy for regular expressions and multi-line strings. Visual Studio…

prapin
- 6,395
- 5
- 26
- 44
1
vote
1 answer
Does Visual Studio 2012 do this correctly? std::move
A question I recently tried to answer seemed to be an error in vs2012's c++11 support.
Specifically, It failed to compile std::map with a non copy-constructible value_type, despite only std::move being used to insert into the map. Either the wrong…

user3125280
- 2,779
- 1
- 14
- 23