Questions tagged [gcc8]

GCC 8 is a major release of the GNU Compiler collection first released in 2018.

Version 8.1 was released on 2018-05-02. Version 8.4 was released on 2020-03-04.

See also:

58 questions
45
votes
9 answers

gcc-8 -Wstringop-truncation what is the good practice?

GCC 8 added a -Wstringop-truncation warning. From https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82944 : The -Wstringop-truncation warning added in GCC 8.0 via r254630 for bug 81117 is specifically intended to highlight likely unintended uses of the…
JRR
  • 3,024
  • 2
  • 13
  • 37
36
votes
5 answers

Unexpected optimization of strlen when aliasing 2-d array

Here is my code: #include #include typedef char BUF[8]; typedef struct { BUF b[23]; } S; S s; int main() { int n; memcpy(&s, "1234567812345678", 17); n = strlen((char *)&s.b) / sizeof(BUF); …
M.M
  • 138,810
  • 21
  • 208
  • 365
18
votes
1 answer

Does the behavior of guaranteed copy elision depend on existence of user-defined copy constructor?

The following code behaves differently with or without user-defined copy constructor under GCC 8.0.1: #include struct S { int i; int *p; S() : i(0), p(&i) {} // S(const S &s) : i(s.i), p(&i) {} // #1 // S(const S &s)…
xskxzr
  • 12,442
  • 12
  • 37
  • 77
9
votes
1 answer

C++17 filesystem using nuwen MinGW on Windows 10

I wanted to try out the new filesystem library in C++17, so tried copying the std::filesystem::current_path example from cppreference.com and compiling it using the latest version (16.0) of the MinGW distribution from nuwen.net on my Windows 10 x64…
rozzy
  • 2,828
  • 6
  • 25
  • 35
7
votes
3 answers

Google Sparsehash uses realloc() on type which is not trivially copyable

Consider this simple program: #include #include int main() { google::dense_hash_map map; map["foo"] = 0; } Compiling with GCC 8.2 and -Wclass-memaccess (or -Wall) produces a…
John Zwinck
  • 239,568
  • 38
  • 324
  • 436
5
votes
3 answers

strncat Wformat-overflow warning when using gcc 8.2.1

I'm using gcc 8.2.1 and trying to build this code: std::string dir = "Documents"; char * _tempname = static_cast (malloc( dir.length() + 14)); strncpy (_tempname, dir.c_str(), dir.length()+1 ); strncat (_tempname, "/hellooXXXXXX", 13); but…
Amr Essam
  • 96
  • 1
  • 1
  • 7
4
votes
0 answers

Question about GCC8's stack-clash-protection clashing with stack-check

I have some code running well under GCC7. It enables fstack-check flag. Now when I switch to GCC8 without code change, I encounter the following error: c1plus: error: ‘-fstack-check=’ and ‘-fstack-clash_protection’ are mutually exclusive. Disabling…
Harper
  • 1,794
  • 14
  • 31
4
votes
1 answer

Building gcc 8.3 [Makefile:955: all] Error 2

I've been trying to build a specific version of GCC (8.3.0) on a new Ubuntu 20.04 machine. However, when I follow the steps at the following link: https://gcc.gnu.org/wiki/InstallingGCC I run into a Makefile error. Steps: wget…
Tex4066
  • 337
  • 4
  • 15
4
votes
1 answer

vector must have the same value as its allocator

This MCVE compiles/runs with gcc 7.3: Please note, this MCVE has been dramatically reduced keeping the error reproduce able, so the code in the Allocator template doesn't make sense but it doesn't affect the constallation! #include #include…
Peter VARGA
  • 4,780
  • 3
  • 39
  • 75
3
votes
1 answer

How to disable devtoolset-8?

I have a bash script that executes the command scl enable devtoolset-8 'echo -e "%__ld $(which ld)\n%__nm $(which nm)\n%__objcopy $(which objcopy)\n%__objdump $(which objdump)\n%__strip $(which strip)"' After completing the assembly, I need to "turn…
R. Key
  • 178
  • 7
3
votes
1 answer

Why does gcc8.3 appear to attempt to compile an unused template function?

Consider (the name of the file is hello.cpp) this code; the idea is to engineer a safe casting of numeric types without loss or overflow. (I'm porting some code from MSVC to g++). #include #include template< typename T/*the…
P45 Imminent
  • 8,319
  • 4
  • 35
  • 78
3
votes
1 answer

Compile error with gcc when in-class initializing unique_ptr of incomplete type to nullptr

I'm writing some code using pimpl idiom with unique_ptr. When I tried to use in-class initialization to set unique_ptr to nullptr by default, gcc gave a compile error, while clang and msvc both successfully compiled the code. And if I didn't use…
X. Sun
  • 315
  • 3
  • 15
3
votes
1 answer

Is this a possible bug in GCC?

My team has an in-house implementation of concepts and we've come across what seems to be a bug with GCC. The following code will work on Visual Studio 2019 but fail on GCC 8.3: #include #include template
ruipacheco
  • 15,025
  • 19
  • 82
  • 138
3
votes
1 answer

Why declaring a return value for a function that doesn't return nothing leads to run-time crash in gcc8 only

In the following code a function is declared/defined as int setYear(int year_h){year = year_h;} (instead of void setYear(...), leading to run-time crash in gcc 8 AND with the flag -O[X] only. Specific questions: What have changed in gcc 8, as it…
Antonello
  • 6,092
  • 3
  • 31
  • 56
3
votes
0 answers

undefined reference to `operator delete(void*, unsigned long)'

I am getting lots of undefined reference to `operator delete(void*, unsigned long)' linking error's while building our c++ code with the gcc 8.2 on RHEL7, earlier we ware building with the gcc 4.8 and it was building fine. ~Destructor() { …
mmm
  • 85
  • 1
  • 8
1
2 3 4