Skip to content

Ambiguity between conversion operator to reference and rvalue reference #2260

@ytimenkov

Description

@ytimenkov

I was playing with trompeloeil mocking framework.

cpptools' static analysis makes lot of use from static_assert's in it and it looks much easier to write tests that it was before with C++98-only frameworks.

However I've noticed that cpptools report some problems which are not problems for compiler.

Type: LanguageService

  • OS and Version: CentOS7 with gcc-6
  • VS Code Version: 1.25.0 0f080e5267e829de46638128001aeb7ca2d6d50e x64
  • C/C++ Extension Version: 0.17.6
  • Other extensions you installed (and if the issue persists after disabling them):
  • A clear and concise description of what the bug is.

To Reproduce
Minimal example:

#include <trompeloeil.hpp>

struct Mock
{
  MAKE_MOCK1(mock_func, void(int param));
};

int main()
{
  Mock m;

  REQUIRE_CALL(m, mock_func(trompeloeil::ne(0)));

  return 0;
}

Expected behavior
This code doesn't have any problems in problem window.

Actual behavior
This problem is reported (reformatted for convenience)
more than one conversion function
from

  • "trompeloeil::make_matcher_return<trompeloeil::wildcard, trompeloeil::lambdas::not_equal, trompeloeil::lambdas::not_equal_printer, int>"

to

  • "trompeloeil::param_list_t<void (int param), 0UL>"

applies:

  • -- function template "trompeloeil::duck_typed_matcher<Pred, T...>::operator V &() const [with Pred=trompeloeil::lambdas::not_equal, T=<int>]"
  • -- function template "trompeloeil::duck_typed_matcher<Pred, T...>::operator V &&() const [with Pred=trompeloeil::lambdas::not_equal, T=<int>]"

Additional information
This mocking framework is single-header and is available from here: https://github.com/rollbear/trompeloeil

@rollbear Are there any references in the standard why this should/may not work?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugfixedCheck the Milestone for the release in which the fix is or will be available.parser

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions