Skip to content

MemoryOutStream MUST (probably) call a base class constructor #174

@musteresel

Description

@musteresel

MemoryOutStream derives from std::ostringstream. The later does not have a default (no argument) constructor before C++11. Apparently the single argument constructor with a default value does not count (didn't look into the standard, but that's what's GCC Version 5.4.0 says. Clang 7.0.0 seems to disagree, however).

Therefore later in GetText() when it calls this->str() I get a segmentation fault:

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff711c446 in std::string::assign(std::string const&) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#0  0x00007ffff711c446 in std::string::assign(std::string const&) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#1  0x000000000046d18a in UnitTest::MemoryOutStream::GetText() const ()
#2  0x0000000000441131 in UnitTest::CheckClose<float, double, double> (results=..., expected=@0x7fffffffcb44: 1.00022995, actual=@0x7fffffffcb48: 1, tolerance=@0x7fffffffcb50: 0.0001, details=...) at /usr/include/unittest++/Checks.h:53

... more, but not relevant here

This was running in a Travis CI build on a Ubuntu 16.04.6 LTS, unittest++ used via apt-get:

Selecting previously unselected package libunittest++-dev.
Preparing to unpack .../libunittest++-dev_1.4.0-3_amd64.deb ...
Unpacking libunittest++-dev (1.4.0-3) ..

Suggested solution: Just call the base constructor without any arguments.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy