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

Ambiguous type name leads to unusual compiling error #25

Open
mattgodbolt opened this issue Jan 11, 2017 · 3 comments
Open

Ambiguous type name leads to unusual compiling error #25

mattgodbolt opened this issue Jan 11, 2017 · 3 comments

Comments

@mattgodbolt
Copy link

In the following example:

#include "trompeloeil.hpp"

namespace A { class Foo {}; }
namespace B { class Foo {}; }
using namespace A;
using namespace B;

struct Bar {
  MAKE_MOCK1(onFoo, void(Foo));
};

The error one gets is:

/home/mgodbolt/dev/algo/mambo/test/trompeloeil.hpp:3319:70: error: template argument 1 is invalid
     std::integral_constant<bool, num == ::trompeloeil::param_list<sig>::size>; \
                                                                      ^
/home/mgodbolt/dev/algo/mambo/test/trompeloeil.hpp:3252:3: note: in expansion of macro ‘TROMPELOEIL_MAKE_MOCK_’
   TROMPELOEIL_MAKE_MOCK_(name,,1, __VA_ARGS__,,)
   ^~~~~~~~~~~~~~~~~~~~~~
.... ~500 more lines in a similar fashion

There's no mention of any ambiguity in the error messages. This is somewhat confusing (but quite possibly not fixable). Of course, the code is incorrect and without the MOCK macro if one writes just struct Bar {void onFoo(Foo); } one gets a more sane error from GCC:

 void onFoo(Foo);

These errors and this behaviour was seen with GCC 6.3 and trompeloeil v22. Perhaps a FAQ entry if there's no way to surface the real underlying error.

@rollbear
Copy link
Owner

Thanks @mattgodbolt. It can be difficult to trick the compiler into providing good information for ill formed programs, but at times it can be done. I'll see what I can do.

@rollbear
Copy link
Owner

Curiously, clang++-3.9 is very clear on what the problem is:

c.cpp:17:28: error: reference to 'Foo' is ambiguous
    MAKE_MOCK1(onFoo, void(Foo));
                           ^
/var/tmp/trompeloeil/trompeloeil.hpp:3576:35: note: expanded from macro 'MAKE_MOCK1'
#define MAKE_MOCK1                TROMPELOEIL_MAKE_MOCK1
                                  ^
c.cpp:5:11: note: candidate found by name lookup is 'A::Foo'
    class Foo {};
          ^
c.cpp:9:11: note: candidate found by name lookup is 'B::Foo'
    class Foo{};
          ^

@rollbear
Copy link
Owner

Reported this as a gcc bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79070

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

No branches or pull requests

2 participants