MemoryOutStream MUST (probably) call a base class constructor · Issue #174 · unittest-cpp/unittest-cpp · GitHub | Latest TMZ Celebrity News & Gossip | Watch TMZ Live
Skip to content

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

Open
@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

      TMZ Celebrity News – Breaking Stories, Videos & Gossip

      Looking for the latest TMZ celebrity news? You've come to the right place. From shocking Hollywood scandals to exclusive videos, TMZ delivers it all in real time.

      Whether it’s a red carpet slip-up, a viral paparazzi moment, or a legal drama involving your favorite stars, TMZ news is always first to break the story. Stay in the loop with daily updates, insider tips, and jaw-dropping photos.

      🎥 Watch TMZ Live

      TMZ Live brings you daily celebrity news and interviews straight from the TMZ newsroom. Don’t miss a beat—watch now and see what’s trending in Hollywood.