Questions tagged [gcc12]

GCC 12 is a major release of the GNU C Compiler, containing new features (as well as many other improvements) relative to GCC 11.x.

GCC 12.1 was released on May 6, 2022.

See GCC 12 Release Series for more information.

23 questions
53
votes
1 answer

Is this GCC 12.1 const problem a bug or feature? "Attempts to call non-const function with const object"

We're seeing C++ code, that compiles successfully in GCC 11.3 and Visual Studio 2022, have issues with GCC 12.1. The code is on Compiler Explorer: https://godbolt.org/z/6PYEcsd1h (Thanks to @NathanPierson for simplifying it some.) Basically, a…
Rob L
  • 2,351
  • 13
  • 23
17
votes
1 answer

GCC v12.1 warning about serial compilation

I have upgraded my whole arch linux system today (12th May, 2022). gcc was also upgraded from v11.2 to v12.1. I tried compiling some of my programs with g++ (part of gcc compiler collection) by the following command: g++ -O3 -DNDEBUG -Os -Ofast -Og…
Darth-CodeX
  • 2,166
  • 1
  • 6
  • 23
5
votes
0 answers

std::is_default_constructible returns the wrong value for a nested class, gcc bug or user error?

MyClass::MyData appears to be default constructible, but std::is_default_constructible_v() returns false. Is this a GCC bug? Code on godbolt at https://godbolt.org/z/qrfz8c7h8. #include #include class…
Rob L
  • 2,351
  • 13
  • 23
4
votes
2 answers

What is the new feature about constexpr std::string with gcc 12.1

case1: #include inline constexpr std::string test(std::string s) noexcept { return s + "xxx"; } int main() { auto s = test("abc"); } c++20 with gcc 12.1 is built okay, c++17 with gcc 12.1 or c++20/17 with gcc 11.1 was…
Jian Zhang
  • 41
  • 2
3
votes
0 answers

Alias to dependent type only allows class types on GCC 12, but allows fundamental types on most other compilers

I found that the code snippet below compiles fine on gcc 11, clang, and MSVC, but starting with gcc 12.1, it gives the error: using Y = typename Derived::template X<1>; // offending line error: 'class Derived::X<1>' resolves to…
gchen
  • 126
  • 6
2
votes
0 answers

`-frecord-gcc-switches` missing flags after gcc 10.4

I used to use -frecord-gcc-switches to embed a version string in a binary. With gcc 10.4, when compiling some c code with -Wall -Werror -O3 -frecord-gcc-switches -DVERSION_THING=123hello, I'd get the following output from readelf -p…
wreckgar23
  • 1,025
  • 9
  • 22
2
votes
1 answer

co_await inside catch no longer compiling with GCC12

I have a code that looks like this: auto func() -> asio::awaitable { try { co_await async_operation(); } catch(boost::system::system_error const& e) { co_return co_await another_async_operation(); } } This code…
Guillaume Racicot
  • 39,621
  • 9
  • 77
  • 141
1
vote
0 answers

Why is GCC throwing filesystem_error cannot copy

I'm working on an app that writes/copies files and thought of updating the code to C++17's filesystem. I'm on Windows 11 using g++ v12.2 with MSYS2 MinGW 64-bit. Below is a summary of my app's behavior. #include #include…
1
vote
1 answer

N-ary tree template metaprogramming

For learning purposes, I'm trying to implement a similar class as the Value object in micrograd. To be more precise, I'm trying to implement it in template metaprogramming. So far, I'm able to do addition and multiplication with the following…
Clément Jean
  • 1,735
  • 1
  • 14
  • 32
1
vote
0 answers

GCC generating corrupted dependency files

I've got a weird issue with compiling GCC that I can't seem to figure out. What I'm trying to compile: gcc v12.2.0 (via make bootstrap) What I'm compiling with: gcc v11.2.0 Configure command: ../configure --prefix=/usr --libdir=/usr/lib64…
Matt Cole
  • 2,552
  • 1
  • 13
  • 21
1
vote
0 answers

Problems with GStreamer compiled from sources in RHEL8 + GCC12

I'm getting strange results with GStreamer 1.20.3 compiled from sources. Target platform is RHEL8 with GCC12 (official Docker image was used as the base one). Python 3.8, Meson and Ninja were installed so compilation/linking passes without any…
IronHawk
  • 365
  • 3
  • 7
1
vote
1 answer

gcc 12 suggesting to add the "pure" attribute

I have written a container class very similar to std::vector. It has a size() member function, which I declared noexcept, const and constexpr. class my_vector { ... constexpr auto size() const noexcept -> size_type { assert(stride_…
alfC
  • 14,261
  • 4
  • 67
  • 118
1
vote
1 answer

Why G++12 vector insert optimization breaks code?

Last time I've compiled my project by new GCC12 and it gave me warning about bad memmove buffer size. The previous versions of the GCC had not report such warnings. The simple code example which presents my situation: #include
Shadasviar
  • 466
  • 5
  • 15
0
votes
0 answers

How get output of address sanitizer while running a daemon

I found this basic daemon code and wanted to see AddressSanitizer summary with daemon process. The process does terminate at strcpy(mem, sentence) in main but I don't see the Summary static void skeleton_daemon() { pid_t pid; /* Fork off…
Nabz C
  • 538
  • 1
  • 9
  • 28
0
votes
1 answer

multiple definition of `pthread_mutex_lock' while compiling with address sanitizer

I am trying to compile with address sanitizer. gcc12 -fsanitize=address -fsanitize=leak -static-libasan my_copy.c -o asan -lpthread Getting this error: /usr/local/bin/ld: my_copy.o: in function `pthread_mutex_lock': my_copy.c:(.text+0x22): multiple…
Nabz C
  • 538
  • 1
  • 9
  • 28
1
2