Questions tagged [compiler-specific]
47 questions
23
votes
1 answer
Why are GHC tuples limited to size 62?
From the the Haskell 98 report:
There is no upper bound on the size of a tuple, but some Haskell implementations may restrict the size of tuples, and limit the instances associated with larger tuples. However, every Haskell implementation must…

AJF
- 11,767
- 2
- 37
- 64
20
votes
1 answer
Why does this code generate different output for different compilers?
I have the following code:
#include
#include
struct C {
int a;
C() : a(0) {}
C(int a) : a(a) {}
};
std::ostream &operator<<(std::ostream &os, const C &c) {
os << c.a;
return os;
}
using T = std::vector;
int…

Matvei
- 217
- 3
18
votes
10 answers
Write a program that will print "C" if compiled as an (ANSI) C program, and "C++" if compiled as a C++ program
Taken from http://www.ocf.berkeley.edu/~wwu/riddles/cs.shtml
It looks very compiler specific to me. Don't know where to look for?

Xolve
- 22,298
- 21
- 77
- 125
17
votes
2 answers
In C++, why do some compilers refuse to put objects consisting of only a double into a register?
In section 20 of Scott Meyer's Effective C++, he states:
some compilers refuse to put objects consisting of only a double into a register
When passing built-in types by value, compilers will happily place the data in registers and quickly send…

Ari Sweedler
- 807
- 7
- 25
16
votes
2 answers
Does using __declspec(novtable) on abstract base classes affect RTTI in any way?
Or, are there any other known negative affects of employing __declspec(novtable)? I can't seem to find references to any issues.

oz10
- 153,307
- 27
- 93
- 128
11
votes
1 answer
Using a class inside the requires-clause for the method of this class
Here is the simple example:
#include
#include
#include
struct MyClass
{
void f( int ) {}
void f( char ) {}
template
requires requires ( MyClass cls, const…

Andrew
- 311
- 1
- 7
11
votes
2 answers
GCC compiler produces error: invalid use of member function while CLang compiler does NOT
I'm using the following program:
In the main function, I want to print the address of the poll_timer function.
The program compiles and runs successfully with clang but not with GCC.
I get the following error with GCC
"709568706/source.cpp: In…

Bilal Ahmed
- 381
- 2
- 13
9
votes
1 answer
What is bivariant parameter? ~ TypeScript
The TypeScript's docs comes with Compiler Options, where the --strictFunctionTypes is defined with its description. Unfortunately, can't get what is bivariant parameter. I tried to understand…

Daniel Danielecki
- 8,508
- 6
- 68
- 94
8
votes
1 answer
Automatically detect C++14 "return should use std::move" situation
My understanding is that in C++17, the following snippet is intended to Do The Right Thing:
struct Instrument; // instrumented (non-trivial) move and copy operations
struct Base {
Instrument i;
};
struct Derived : public Base {};
struct…

Quuxplusone
- 23,928
- 8
- 94
- 159
8
votes
2 answers
C++11 feature checking
How do I check for presence of individual C++0x/C++11 language features? I know Clang has a nice system for this. What about GCC, Visual Studio or Boost? I guess one way to do it is to detect the compiler version and relate that to the features…

Nordlöw
- 11,838
- 10
- 52
- 99
7
votes
1 answer
Are nested parentheses allowed in function type alias declaration?
The following code can be compiled with gcc-13 and clang-16, but MSVC reports multiple errors
using foo_type = void ((((int, const char*)))); // (1)
// Compiler messages for line (1):
// clang-16: ok.
// gcc-13: ok.
// MSVC-v19: error…

Igor G
- 1,838
- 6
- 18
5
votes
3 answers
`std::views::split` on MSVC
I want to split a string by a token with std::views::split, and for each retrieved substring invoke the std::from_chars function.
Here is an MRE (https://godbolt.org/z/1K71qo9s4) that compiles successfully on GCC but fails to compile on…

Andrew
- 311
- 1
- 7
4
votes
1 answer
Intel Compiler - error: identifier "alignof" is undefined
I'm trying to run an example of the alignof operator.
#include
struct Empty {};
struct Foo {
int f2;
float f1;
char c;
};
int main()
{
std::cout << "alignment of empty class: " << alignof(Empty) << '\n'
…

dspereira004
- 91
- 1
- 8
3
votes
2 answers
Can the address of a template parameter be used in instantiating another template?
I read a trick somewhere how to convert a constant literal value to a static variable (this can be useful in a template). Check out the makeStatic function in my example code which does this.
I tried to use the result of makeStatic to another call…

geza
- 28,403
- 6
- 61
- 135
3
votes
2 answers
Thread sanitizer complaining of unexpected memory map
I am trying to test the usage of -fsanitize=thread for gcc, and its complaining of unexpected memory mapping, maybe there might have been some change in the kernel, and thats the reason for it. Is there any thing I could do to make it work ?
This is…

mfrw
- 99
- 1
- 11