gcc5

std::string class inheritance and tedious c++ overload resolution

落花浮王杯 提交于 2019-12-07 01:48:28
问题 I need to extend std::basic_string to work over path strings and different operator+ : #include <string> template <class t_elem, class t_traits, class t_alloc> class path_basic_string : public std::basic_string<t_elem, t_traits, t_alloc> { public: using base_type = std::basic_string<t_elem, t_traits, t_alloc>; path_basic_string() = default; path_basic_string(const path_basic_string & ) = default; path_basic_string & operator =(const path_basic_string &) = default; path_basic_string(const base

Undefined reference in clang when linking to a library compiled with GCC5

こ雲淡風輕ζ 提交于 2019-12-06 23:28:54
问题 I try to use the ubuntu 15.10 repository version of libmuparser (package libmuparser2v5). Compiling with gcc works fine, but not with clang. I dug deeper into this to come up with the following minimal (not) working example and a few questions. Consider a library with a simple class that takes a string and returns a string . testlib.h : #pragma once #include <string> struct Test { std::string str; void set(std::string s); std::string get(); }; testlib.cpp : #include "testlib.h" void Test::set

std::string class inheritance and tedious c++ overload resolution

蓝咒 提交于 2019-12-05 05:31:09
I need to extend std::basic_string to work over path strings and different operator+ : #include <string> template <class t_elem, class t_traits, class t_alloc> class path_basic_string : public std::basic_string<t_elem, t_traits, t_alloc> { public: using base_type = std::basic_string<t_elem, t_traits, t_alloc>; path_basic_string() = default; path_basic_string(const path_basic_string & ) = default; path_basic_string & operator =(const path_basic_string &) = default; path_basic_string(const base_type & r) : base_type(r) { } path_basic_string(base_type && r) : base_type(std::move(r)) { } }; using

Undefined reference in clang when linking to a library compiled with GCC5

一笑奈何 提交于 2019-12-05 03:34:54
I try to use the ubuntu 15.10 repository version of libmuparser (package libmuparser2v5). Compiling with gcc works fine, but not with clang. I dug deeper into this to come up with the following minimal (not) working example and a few questions. Consider a library with a simple class that takes a string and returns a string . testlib.h : #pragma once #include <string> struct Test { std::string str; void set(std::string s); std::string get(); }; testlib.cpp : #include "testlib.h" void Test::set(std::string s) { str = s; } std::string Test::get() { return str; } This is compiled with gcc 5.2.1 as

Output data type of sizeof() operator

时光怂恿深爱的人放手 提交于 2019-12-04 00:23:12
问题 I am using Ubuntu 16.04.5 and GCC version 5.4.0. I was playing with sizeof() operator, wrote the code below: #include <stdio.h> int main(int argc, char *argv[]){ long int mylint = 31331313131.1313; printf("size of long int is %d\n", sizeof(mylint)); printf("size of long int is %d\n", sizeof(long int)); return 0; } I tried to compile using gcc -o ... ... command and was expecting: size of long int is 8 size of long int is 8 But I got the following error: fl_double_lint.c: In function ‘main’:

Trying to get CUDA 7.5 to work with GCC 5.x

こ雲淡風輕ζ 提交于 2019-12-02 02:35:47
So, if you try to use nvcc when the system GCC is version 5 and up, you get an "unsupported version" error. But - I've heard people report that they've just commented this out and that CUDA 7.5 "works for them" with GCC 5.x . When I do the same, however (the check is in $CUDA_DIR/host_config.h ), and compile something, I get the following errors: /usr/lib/gcc/x86_64-redhat-linux/5.3.1/include/mwaitxintrin.h(36): error: identifier "__builtin_ia32_monitorx" is undefined /usr/lib/gcc/x86_64-redhat-linux/5.3.1/include/mwaitxintrin.h(42): error: identifier "__builtin_ia32_mwaitx" is undefined and a

Trying to get CUDA 7.5 to work with GCC 5.x

陌路散爱 提交于 2019-12-02 02:26:00
问题 So, if you try to use nvcc when the system GCC is version 5 and up, you get an "unsupported version" error. But - I've heard people report that they've just commented this out and that CUDA 7.5 "works for them" with GCC 5.x . When I do the same, however (the check is in $CUDA_DIR/host_config.h ), and compile something, I get the following errors: /usr/lib/gcc/x86_64-redhat-linux/5.3.1/include/mwaitxintrin.h(36): error: identifier "__builtin_ia32_monitorx" is undefined /usr/lib/gcc/x86_64

g++4.9 and g++5 different behaviour when narrowing in initializing list

走远了吗. 提交于 2019-11-30 09:21:05
问题 Consider this code: #include <iostream> int main() { int i{10.1}; // narrowing, should not compile std::cout << i << std::endl; } According to the C++11 standard, it should not compile (narrowing in brace initialization is forbidden.) Now, compiling with g++4.9.2 -std=c++11 only emits a warning warning: narrowing conversion of '1.01e+1' from 'double' to 'int' inside { } [-Wnarrowing] Removing the -std=c++11 flag results in a warning regarding the brace init, but not any narrowing: warning:

g++4.9 and g++5 different behaviour when narrowing in initializing list

跟風遠走 提交于 2019-11-29 15:31:05
Consider this code: #include <iostream> int main() { int i{10.1}; // narrowing, should not compile std::cout << i << std::endl; } According to the C++11 standard, it should not compile (narrowing in brace initialization is forbidden.) Now, compiling with g++4.9.2 -std=c++11 only emits a warning warning: narrowing conversion of '1.01e+1' from 'double' to 'int' inside { } [-Wnarrowing] Removing the -std=c++11 flag results in a warning regarding the brace init, but not any narrowing: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11 On the other hand, g++5 doesn't

New option in GCC 5.3: -fno-semantic-interposition

帅比萌擦擦* 提交于 2019-11-29 04:19:28
GCC 5.3 has added a new option: -fno-semantic-interposition A new -fno-semantic-interposition option can be used to improve code quality of shared libraries where interposition of exported symbols is not allowed. This sounds like this is something useful for C++ projects where interposition can't be used for whatever reason, but where latency is a concern. However, the description is fairly vague. Is anyone able to clarify how this option works exactly? -fno-semantic-interposition can significantly improve performance of code in shared libraries but may change semantics in some cases. By