Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#6002 closed defect (fixed)

ogr_autocad_services.cpp has incorrect logic on a C++14 compiler

Reported by: etresoft Owned by: warmerdam
Priority: normal Milestone: 2.0.1
Component: default Version: unspecified
Severity: normal Keywords:


The C++ std::string::assign method has changed in C++14. The ACAdjustText method is relying on cast to a C string in its assign operations. While ogr_autocad_services.cpp still compiles, but now uses a different assign method resulting in incorrect logic. I found the error while building and testing GDAL on Xcode 6.3.2. I am building the 1.11.2 branch, but the same logic seems to be present in the 2.0 branch.

Attachments (1)

0001-Make-compatible-with-C-14.patch (2.2 KB ) - added by etresoft 8 years ago.
Patch file for C++ compatibility.

Download all attachments as: .zip

Change History (5)

by etresoft, 8 years ago

Patch file for C++ compatibility.

comment:1 by etresoft, 8 years ago

PS: I was comparing tests against Linux running Ubuntu 14.04. The new code doesn't seem to have broken the Linux build.

comment:2 by Even Rouault, 8 years ago

trunk r29363, branches/2.0 r29364 (post RC2) "DXF: make it compatible with C++11/C++14 (patch by etresoft, #6002)"

comment:3 by Even Rouault, 8 years ago

Milestone: 2.0.1
Resolution: fixed
Status: newclosed

comment:4 by Even Rouault, 8 years ago

Post analysis: the issue is with C++14 only.

The culprit here is was our use of the CPLString class extending std::string with a implicit conversion operator to const char*.

Previously string& assign (const char* s, size_t n) was used when a CPLString was passed. But in C++14, string& assign (const string& str, size_t subpos, size_t sublen = npos) was now used since the sublen argument became optional.

Note: See TracTickets for help on using tickets.