All Questions
2,251
questions
0
votes
0
answers
13
views
Why does clang fail on mabi but not gcc?
Given my file test.c:
#include <stdarg.h>
int a(int b, ...) { __builtin_ms_va_list list; __builtin_ms_va_start(list,b); }
I try:
$ clang -m64 -c -g -O2 -mabi=ms test.c -Wall -Wextra
which ...
1
vote
1
answer
70
views
gcc and clang disagree on using alias templates as template template argument [duplicate]
The code below compiles using gcc 14.1.1 but clang 18.1.8 doesn't accept it. Which one is right and is there any workaround?
template <template <typename...> class T>
struct s {
...
1
vote
1
answer
79
views
Why do I get a "for declaration does not refer into a class, class template or class template partial specialization" on Clang and not GCC [duplicate]
I currently have this block of code which does not throw a compiler error on GCC, but throws this compiler error on clang:
error: nested name specifier 'MyEnum::' for declaration does not refer into ...
0
votes
0
answers
24
views
Using GCC on Apple M2 Max Laptop
I can't use GCC because clang interferes with it. I used brew install gcc, and it downloaded correctly but I can't use it because clang overrides it. I added the path into my /.bash_profile so when I ...
1
vote
1
answer
128
views
is implementation allowed to reserve arbitrary names in global scope?
I've been porting a windows library to linux and it's failing on declaration of struct error_t. Both gcc and clang are giving an error message:
/usr/include/x86_64-linux-gnu/bits/types/error_t.h:22:...
4
votes
1
answer
105
views
Can auto be used for static class variable definition?
Consider this simple example:
struct Class {
struct Inner {};
static Inner a;
};
I cannot define this a with this syntax:
auto Class::a = Inner{}; - gcc and msvc both complaint in a similar ...
1
vote
0
answers
30
views
undefined references using gcc link-time optimizer
I'm tring to use gcc link-time optimizer, but encounter some issue related to the gcc linker cannot correctly resolving references to symbols in 'newlib_syscalls.c'. However, same source code , ...
12
votes
2
answers
2k
views
Logical AND (&&) does not short-circuit correctly in #if
For code:
#if defined(FOO) && FOO(foo)
#error "FOO is defined."
#else
#error "FOO is not defined."
#endif
MSVC 19.38 prints:
<source>(1): warning C4067: ...
5
votes
1
answer
175
views
Is there a reason that 8 byte std::array comparisons seem to be producing different assembly for char vs. std::byte?
I noticed 8 byte std::array comparisons seem to be producing assembly different from bit_casting. GCC seems to do what I expect for a char array, but clang generates an extra mov instruction (spilling ...
6
votes
1
answer
129
views
How to print non-structural results of constexpr functions at compile time with clang++?
I'm writing a constexpr code and I would like to inspect computed values at compile time.
The usual trick is to do something like this:
struct ReturnValue
{
int value1;
int value2;
};
...
7
votes
1
answer
229
views
Class template static field initialization different results on GCC and Clang
Consider the following C++ code example:
#include<iostream>
class B {
public:
int val;
B(int v):val(v){
std::cout<< val << "\n";
}
};
template<...
7
votes
2
answers
215
views
Unexpected result with `std::views::transform`, probably caused by "unnamed temporary"
The following code (godbolt):
#include <iostream>
#include <vector>
#include <ranges>
struct S
{
float x = 150.f;
S f() const
{
return *this;
}
};
int main()...
0
votes
0
answers
75
views
GCC/clang and Visual C++ structure compatibility issue
I ran into an error in our codebase when mixing compilers. This happens in a production environment which I work in with a third party library. I would very much appreciate any insight into how I ...
2
votes
1
answer
87
views
deleted template class constructor but there is a specialization behaves differently with clang and gcc
I am trying to understand the behavior.
I am created a template class with a deleted constructor, then I have specialized it for the int type. My goal would be to create instances only for int (...
0
votes
0
answers
39
views
Why can't Clang/lld find `__dlopen`, `__dlclose` and `__dlsym`?
Following from this question, I am trying to compile a C/C++ project that targets an old Linux system. To have the old libraries at hand, I made a copy of the target root fs, and since GCC has ...