https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67209

            Bug ID: 67209
           Summary: G++ generates incorrect code for boost::filesystem
           Product: gcc
           Version: 5.2.0
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bear at bears dot org
  Target Milestone: ---

I have code which worked fine using boost::filesystem with gcc 4.8.2 but which
segfaults with 5.2.0.  Here is a gdb session where it falls apart.

Breakpoint 1, FolderNotify::configure (this=0xd4b960 <externalLogsFolder>,
fname=..., mask=776) at common/FileNotify.cpp:116
116             bfs::create_directories(dirPath);
(gdb) print dirPath.m_pathname.size()
$40 = 20
(gdb) step
boost::filesystem::create_directories (p=...) at
/usr/local/include/boost/filesystem/operations.hpp:523
523       bool create_directories(const path& p) {return
detail::create_directories(p);}
(gdb) print p.m_pathname.size()
$41 = 20
(gdb) step
boost::filesystem::detail::create_directories (p=..., ec=0x0) at
libs/filesystem/src/operations.cpp:930
930         error_code local_ec;
(gdb) print p.m_pathname.size()
$42 = 15443128

As you can see, the value returned by p.m_pathname.size() goes haywire in the
handoff from the inline header to the actual cpp.  Here is a printout of the
structure of p.  The _M_string_length variable goes missing even though the
variables are all references to the same structure:

Breakpoint 1, FolderNotify::configure (this=0xd4b960 <externalLogsFolder>,
fname=..., mask=776) at common/FileNotify.cpp:116
116             bfs::create_directories(dirPath);
(gdb) print dirPath
$44 = {static preferred_separator = 47 '/', m_pathname = {static npos =
18446744073709551615, 
    _M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> =
{<No data fields>}, <No data fields>}, 
      _M_p = 0xebea40 "/tmp/sacExternalLogs"}, _M_string_length = 20,
{_M_local_buf = "\036", '\000' <repeats 14 times>, _M_allocated_capacity =
30}}}
(gdb) step
boost::filesystem::create_directories (p=...) at
/usr/local/include/boost/filesystem/operations.hpp:523
523       bool create_directories(const path& p) {return
detail::create_directories(p);}
(gdb) print p
$45 = (const boost::filesystem::path &) @0xd4b990: {static preferred_separator
= 47 '/', m_pathname = {static npos = 18446744073709551615, 
    _M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> =
{<No data fields>}, <No data fields>}, 
      _M_p = 0xebea40 "/tmp/sacExternalLogs"}, _M_string_length = 20,
{_M_local_buf = "\036", '\000' <repeats 14 times>, _M_allocated_capacity =
30}}}
(gdb) step
boost::filesystem::detail::create_directories (p=..., ec=0x0) at
libs/filesystem/src/operations.cpp:930
930         error_code local_ec;
(gdb) print p
$46 = (const boost::filesystem::path &) @0xd4b990: {static preferred_separator
= 47 '/', m_pathname = {static npos = <optimized out>, 
    _M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> =
{<No data fields>}, <No data fields>}, 
      _M_p = 0xebea40 "/tmp/sacExternalLogs"}}}

Reply via email to