Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Catch_global_namespace_dummy a complete type #1110

Closed
AndrewPaxie opened this issue Nov 19, 2017 · 1 comment
Closed

Make Catch_global_namespace_dummy a complete type #1110

AndrewPaxie opened this issue Nov 19, 2017 · 1 comment

Comments

@AndrewPaxie
Copy link

Description

Compile the unit tests for the Trompeloeil mock object library,
in this particular combination of C++ Standard Library and compiler,

Operating system: Ubuntu 17.10 (Artful Aardvark)
Compiler: g++-7 (from package g++-7 7.2.0-8ubuntu3)
Standard C++ Library: libc++ (from package libc++-dev:amd64 3.9.1-3)
Catch version: v2.0.1

Expected result: The unit tests compile and pass.

Actual result: The compilation fails with an error message,

/usr/include/c++/v1/type_traits:2928:50:
error: invalid use of incomplete type ‘struct Catch_global_namespace_dummy’
   decltype(__is_constructible_test(declval<_Tp>(), declval<_Args>()...))
            ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Other combinations that fail: any other supported version of g++ with libc++.

Other combinations that succeed:

  • Any supported version of g++ with libstd++-v3.
  • Any supported version of clang++ with libstdc++-v3.
  • Any supported version of clang++ with libc++.

Steps to reproduce

# Assume packages g++-7, libc++-dev are installed

$ mkdir trompeloeil-scratch
$ git clone https://github.com/AndrewPaxie/trompeloeil trompeloeil-scratch
$ cd trompeloeil-scratch
$ git checkout c++11

$ wget https://raw.githubusercontent.com/catchorg/Catch2/v2.0.1/single_include/catch.hpp

$ g++-7 -std=c++14 -nostdinc++ \
-isystem/usr/include/c++/v1 \
-ftemplate-backtrace-limit=0 \
-Wall -Wextra -Wpedantic -Wshadow \
-I . -I ./include \
-o compiling_tests \
test/compiling_tests.cpp test/compiling_tests_11.cpp test/compiling_tests_14.cpp \
-nodefaultlibs -lc++ -lc++abi -lm -lc -lgcc_s -lgcc

Extra information

Supposed cause

In include/internal/catch_tostring.h there is the code

// We need a dummy global operator<< so we can bring it into Catch namespace later
struct Catch_global_namespace_dummy;
std::ostream& operator<<(std::ostream&, Catch_global_namespace_dummy);

namespace Catch {
    // Bring in operator<< from global namespace into Catch namespace
    using ::operator<<;

Suggested fix

When Catch_global_namespace_dummy is changed to

struct Catch_global_namespace_dummy {};

the Trompeloeil unit test code compiles with success.

@AndrewPaxie AndrewPaxie changed the title Make Catch_global_namespace_dummy a complete type Make Catch_global_namespace_dummy a complete type Nov 19, 2017
AndrewPaxie referenced this issue in rollbear/trompeloeil Nov 19, 2017
@horenmar
Copy link
Member

Interesting.

As far as I know, there is no problem with making it complete, so I am going to fix it soonish.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants