- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Given test.cpp
#include <string> #include <cassert> class CPLString : public std::string { public: CPLString( const std::string &oStr ) : std::string( oStr ) {} }; int main() { CPLString osTest("test"); CPLString osTest2( 0 ? std::string() + osTest : osTest ); assert( !osTest.empty() ); }
$ icc -g -Wall -Wextra -std=c++11 test.cpp -o test && ./test
test: test.cpp:14: int main(): Assertion `!osTest.empty()' failed.
Whereas without -std=c++11 it doesn't assert.
On Ubuntu 16.04 64 bit. The same compiled with gcc 5.4 or clang 3.8 in C++11 doesn't assert.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi there,
I didn't see the assertion with your test case.
Thanks,
Viet
[vahoang@orcsle127 tmp]$ cat test.cpp
#include <string>
#include <cassert>
class CPLString : public std::string
{
public:
CPLString( const std::string &oStr ) : std::string( oStr ) {}
};
int main()
{
CPLString osTest("test");
CPLString osTest2( 0 ? std::string() + osTest : osTest );
assert( !osTest.empty() );
}
[vahoang@orcsle127 tmp]$ icc -g -Wall -Wextra -std=c++11 test.cpp -o test && ./test
[vahoang@orcsle127 tmp]$ icc -V
Intel(R) C Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 17.0.1.132 Build 20161005
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Viet, are you using the a 6.0 version of the GNU header files? I can reproduce it with the latest compiler if I use them.
I've reduced it to the following which outputs "FAILED" with the Intel compiler but not with GNU or clang.
extern "C" int printf(const char*,...);
struct string
{
string() {}
string(const string& __str) {}
string(const char* __s) {}
string(string&& __str) noexcept { printf("FAILED\n"); }
};
struct CPLString : public string
{
CPLString( const string &oStr ) : string( oStr ) {}
};
int main()
{
CPLString osTest("test");
CPLString osTest2( 0 ? string() : osTest );
return 0;
}
I submitted a bug report in our bugs database as DPD200416593.
Thanks for reporting it.
A workaround would be to do the following under #ifdef OK:
#ifdef OK
CPLString osTest2( 0 ? CPLString(std::string() + osTest) : osTest );
#else
CPLString osTest2( 0 ? std::string() + osTest : osTest );
#endif
Judy
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page