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
3
votes
1 answer

Segfault when using std::function class member with compiler optimizations

I have a quite simple code example which crashes when optimized with -O2 under gcc 8.2.0 #include #include #include template class Lambda_Expression { using Lambda =…
GPMueller
  • 2,881
  • 2
  • 27
  • 36
3
votes
2 answers

Why stack grows by 16 bytes in this disassembly, when I only have one 4 byte local variable?

I'm having trouble understanding why the compiler chose to offset the stack space in the way it did with the code I wrote. I was toying with Godbolt's Compiler Explorer in order to study the C calling convention, when I came up with a simple code…
Arthur Araruna
  • 339
  • 3
  • 12
3
votes
1 answer

gcc-8 Wstringop-truncation

I'm trying to fix some C code where gcc-8 complains about Wstringop-truncation (code is here) When compiling that code on a server which I can not control neither can add pragma statements nor can disable Wstringop-truncation diagnostics, the…
user1600826
3
votes
1 answer

function declaration isn’t a prototype

The following code compiles fine: #include #include #include #include extern int errno ; int main ( void ) { FILE *fp; int errnum; fp = fopen ("testFile.txt", "rb"); if ( fp == NULL ) …
Michi
  • 5,175
  • 7
  • 33
  • 58
2
votes
1 answer

How to sort std::set of indices according to the vector of sorted indices?

I have a class MyClass, which operates with some double values beta, stored as a class member, in it's member function g. It sorts them and stores the permutation in the class member std::vector sorted_beta_ind: double MyClass::g() { // ... …
Verloren
  • 859
  • 1
  • 8
  • 18
2
votes
0 answers

Clarification required on gcc option -mcmodel=medium

While compiling one of our dependent tool, a long list relocation error is showing up while linking: SomeLibrary.a(SomeObject.o)(.text._bla_bla_bla): error: relocation overflow collect2: error: ld returned 1 exit status cook: command g++: exit…
Foobar-naut
  • 111
  • 3
  • 11
2
votes
1 answer

c++ const_cast gcc 8.2.1 -Wignored-qualifiers bug?

The following program produces this with gcc 8.2.1: warning: type qualifiers ignored on cast result type [-Wignored-qualifiers] int * const ptrCast = const_cast(ptr); int main() { int i = 0; …
1
vote
1 answer

gcc-8: command not found (while installing randomForest)

I'm trying to install "randomForest" on R 3.6.3 as below: urlPackage <- "https://cran.r-project.org/src/contrib/Archive/randomForest/randomForest_4.6-14.tar.gz" install.packages(urlPackage, repos=NULL,…
klein
  • 13
  • 3
1
vote
1 answer

warning: ‘/name0’ directive output may be truncated writing 10 bytes into a region of size between 1 and 4096 [-Wformat-truncation=]

#DEFINE LENGTH 4096 warning: ‘/name0’ directive output may be truncated writing 10 bytes into a region of size between 1 and 4096 [-Wformat-truncation=] snprintf(head_list->cname, LENGTH, "%s/name0", cpath); …
qwerty
  • 85
  • 2
  • 6
1
vote
0 answers

Linker error : Definition of static constexpr initializer list member variable in discard section

I have something similar to the following code : include/Group.hpp #pragma once #include struct Group { static constexpr std::initializer_list v = {1,2,3}; }; include/foo.hpp #pragma once void…
Eskilade
  • 84
  • 2
  • 11
1
vote
1 answer

steady_clock::now() return type invalid with gcc

I have the following code: #include struct SteadyTime : std::chrono::steady_clock::time_point { using time_point::time_point; static SteadyTime now() { return clock::now(); } }; This works well with Visual Studio 2019…
ruipacheco
  • 15,025
  • 19
  • 82
  • 138
1
vote
2 answers

How to fix compilation error with gcc8 while specializing swap function/

I'm trying to compile code which specialize the function std::swap for my class. But I'm facing an issue that occurs because of rvalue constructor (it works when I comment the line) I am compiling with g++ (GCC) 8.2.1 20180905 (Red Hat 8.2.1-3) and…
1
vote
1 answer

How to add Debug symbols for GCC 8.1.0?

I've updated the version of the GCC that I'm using from 4.2.1 to 8.1.0. (This is the only thing that I've changed) The problem is that after I did it the debug symbols were gone. I'm running GDB only with "-g" option. With gcc v8.1.0, there are no…
1
vote
1 answer

GCC8.2 How to enable warning: array subscript is above array bounds [-Warray-bounds]

I want to enable array boundary checking under gcc8.2, so it can help to check if array subscript is out of bound during compilation period, it may give the warning like: array subscript is above array bounds [-Warray-bounds] I made a demo using…
leiyc
  • 903
  • 11
  • 23
1
vote
2 answers

How should I circumvent -Wformat-truncation?

Suppose I have a function taking an int *p which I know for a fact only points to values between 0 and 99. However, the compiler doesn't know that, so if I write: char buffer[3]; snprintf(buffer, "%02d", *p); I get a warning (at least, on GCC 8.x)…
einpoklum
  • 118,144
  • 57
  • 340
  • 684