g++4.8

Size of empty vector

旧时模样 提交于 2020-01-23 03:03:06
问题 The following program on running with g++ 4.8.2 gave the output 12 on a 32-bit Linux system: vector<char> v; cout << sizeof(v) << endl; I saw this and know that sizeof(v) could be implementation specific. Still, I was wondering what might be causing that vector to have a size of 12. What I think is that the iterators v.begin() and v.end() might be contributing to 8 bytes of the size. Am I correct? If yes, what is contributing to the remaining 4 bytes of size? If not, what are these 12 bytes

Square root of negative zero

早过忘川 提交于 2020-01-13 08:48:12
问题 Under g++ version 4.8.0 (32-bit mingw), the square root of -0.0 (binary representation 0x8000000000000000) is NAN. But I could have sworn that earlier versions (I'm not sure which, but the last time I ran my full test suite) returned simply 0.0, which seems more sensible to me. Is this right? Has something in the C++ standard changed, or is this a g++ change? 回答1: This is a non-standard* behavior of the MinGW environment (that I have also observed, indirectly, through a customer for whom the

Square root of negative zero

荒凉一梦 提交于 2020-01-13 08:48:03
问题 Under g++ version 4.8.0 (32-bit mingw), the square root of -0.0 (binary representation 0x8000000000000000) is NAN. But I could have sworn that earlier versions (I'm not sure which, but the last time I ran my full test suite) returned simply 0.0, which seems more sensible to me. Is this right? Has something in the C++ standard changed, or is this a g++ change? 回答1: This is a non-standard* behavior of the MinGW environment (that I have also observed, indirectly, through a customer for whom the

Why can I initialize a regular array from {}, but not a std::array

不羁的心 提交于 2019-12-22 04:09:38
问题 This works: int arr[10] = {}; All elements of arr are value-initialized to zero. Why doesn't this work: std::array<int, 10> arr({}); I get the following warning from g++ (version 4.8.2): warning: missing initializer for member ‘std::array<int, 10ul>::_M_elems’ 回答1: There are two issues one which is a matter of style and the warning. Although it may not be obvious, aggregate initialization is happening on a temporary which is then being used as an argument to the copy constructor. The more

g++-5.1.1 warns about unused variable only when optimization flag is used

早过忘川 提交于 2019-12-21 04:16:18
问题 In a large project, I've been getting some compiler warnings from g++-5.1.1 only when building the release version (which uses optimization flags) but not while building the debug version (which disables most compiler optimization). I've narrowed down the problem to a minimal example listed below with commands to reproduce the problem. The problem does not occur if I use g++-4.8.4. Is this a bug in g++-5.1.1? Or, is this code doing something that is legitimately wrong and warrants that

eliminate unnecessary copies when calling C++/STL algorithms

僤鯓⒐⒋嵵緔 提交于 2019-12-21 02:03:52
问题 I've coded the following example in order to better illustrate my questions. In the code below, I introduce a function object (i.e., funObj ). In funObj class's definition an integral member variable called id is defined to hold the ID of every funObj constructed and a static integral member variable n to count the funObj objects created. Thus, every time an object funObj is constructed n is increased by one and its value is assigned to the id field of the newly created funObj . Furthermore,

Odd linker issue “relocation R_X86_64_32 against” - not a typical -fPIC issue

☆樱花仙子☆ 提交于 2019-12-11 20:39:15
问题 I have an odd problem when trying to create a fat shared library on Ubuntu 14.04 (64). The error messages are what you typically get if you forgot to add -fPIC or link to a wrong architecture library: /usr/bin/ld: /usr/lib/libproj.a(pj_init.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC /usr/lib/libproj.a: error adding symbols: Bad value The first static library is compiled like this: gcc -c -fPIC -m64 NativeDB.c After

newer version of Cygwin/gcc does not select _WIN32 branch, but older version does

纵然是瞬间 提交于 2019-12-11 08:33:44
问题 I have taken over the use of an existing FPGA verification system. It uses an Opal Kelly software (Windows) that provides a C++ programming API to perform I/O on an FPGA. The system runs on a Windows machine but is initiated through a Cygwin terminal. When I want to run a simulation, I invoke a script using a command line with the switch "-hdl" to use Opal Kelly simulation libraries in Modelsim; when I want to run a test in hardware, I compile a different set of Opal Kelly-provided source

Sublime Text 2 使用 g++4.8 编译 C++11 程序

左心房为你撑大大i 提交于 2019-12-07 18:55:51
系统中装了 g++4.8.1 后(详见《 Ubuntu 12.04 安装 gcc-4.8 及 gdb 7.6 》), 为了可以在 Sublime Text 2 中 直接 使用快捷键 Ctrl+B 和 Shift+Ctrl+B 进行编译和编译运行C++11程序, 需按以下步骤配置新的 Build System. 1. 打开 Sublime Text 2, Tools →Build System →New Build System... 2. 在新打开的文件中填入以下内容 { "cmd": ["g++-4.8", "${file}", "-o", "${file_path}/${file_base_name}", "-std=c++11"], "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$", "working_dir": "${file_path}", "selector": "source.c, source.c++", "variants": [ { "name": "Run", "cmd": ["bash", "-c", "g++-4.8 -std=c++11 '${file}' -o '${file_path}/${file_base_name}' && '${file_path}/${file_base_name}

Why can I initialize a regular array from {}, but not a std::array

懵懂的女人 提交于 2019-12-05 03:01:55
This works: int arr[10] = {}; All elements of arr are value-initialized to zero. Why doesn't this work: std::array<int, 10> arr({}); I get the following warning from g++ (version 4.8.2): warning: missing initializer for member ‘std::array<int, 10ul>::_M_elems’ There are two issues one which is a matter of style and the warning. Although it may not be obvious, aggregate initialization is happening on a temporary which is then being used as an argument to the copy constructor. The more idiomatic to do this initialization would be as follows: std::array<int, 10> arr = {}; Although this still