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

Catch won't compile, throwing some incomprehensible template errors #450

Closed
CelticMinstrel opened this issue Jun 30, 2015 · 9 comments
Closed

Comments

@CelticMinstrel
Copy link

I can't compile the minimal Catch program (just the #define CATCH_CONFIG_MAIN and #include "catch.hpp") with XCode 4.5.2 (clang 4.2 or so) on Mac OSX Lion, using the default version of libc++. The error log is rather long, but you can view it here. I tried to go through the errors and figure out the cause, but was unable to make any progress.

I just downloaded the single-include header earlier today from here on github, so it's presumably the latest copy. Is there anything I can do to fix this issue, or could it be that my compiler/library is just too old?

@refi64
Copy link

refi64 commented Jun 30, 2015

clang 4.2 or so

The latest version is 3.6.1...

@philsquared
Copy link
Collaborator

I don't have a copy of Xcode 4 around, still, to try this on - but from the error message you posted (thanks for that) it looks like it's the std::map keyed on the type it's a member of that's an issue.
It looks like it's only the use of that map (in the methods) that it's having trouble with (seems to be from my scanning of the errors). So I've separated the implementation of those methods out.

This is included in v1.2.1, so please check that out and let me know if it fixes it for you.

@CelticMinstrel
Copy link
Author

I just redownloaded from the link in the readme, and the problem still occurs. Except for line/column numbers, the error messages are identical.

EDIT: Since they are basically identical, I replaced the errors at the previous link with the new ones.

There's also an error on the following code which makes no sense (it was present before as well, but I fixed it as it seemed a trivial issue unrelated to the main problem):

inline TrackedSection* TrackedSection::findChild( std::string const& childName ) {
    TrackedSections::iterator it = m_children.find( childName );
    return it != m_children.end()
        ? &it->second
        : NULL;

Reversing the order of the logic (ie, using == instead of != and reversing the order of the other two operands) seems to fix it, though I can't comprehend why it occurs in the first place (the actual error is below; I imagine you'll agree it doesn't make sense):

~/Documents/Programming/Blades Of Exile/src/../rsrc/../test/catch.hpp:4978:20: error: expected ':'
            ? &it->second
                   ^
~/Documents/Programming/Blades Of Exile/src/../rsrc/../test/catch.hpp:4978:13: note: to match this '?'
            ? &it->second
            ^
~/Documents/Programming/Blades Of Exile/src/../rsrc/../test/catch.hpp:4978:20: error: use of undeclared identifier 'second'
            ? &it->second

@kirbyfan64 - Well, clang --version returns Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn). Maybe I just parsed out the wrong portion of that for the version.

@philsquared
Copy link
Collaborator

That's a shame.
I think the other error you are seeing (with the ?: operator) is a consequence of the first (because the type of second is incomplete it can't match it against NULL)

@philsquared
Copy link
Collaborator

actually that can't be the case as TrackedSection is no longer incomplete at that point. Hmmm

@refi64
Copy link

refi64 commented Jun 30, 2015

@CelticMinstrel What about trying a newer version of Clang? I know that 3.2 was a bit buggier than later releases and had given be trouble a few times.

Whatever the issue is, it's definitely not present in newer versions: I use Clang 3.6 and have never encountered this issue.

@CelticMinstrel
Copy link
Author

If I use a newer version of clang it doesn't work correctly with XCode due to APIs changing or something. Or at least, that was the case the last time I tried (which admittedly was a few years ago, and I think I might've updated XCode since then, so it might be worth trying again; just have to remember how). Keep in mind though that my XCode is also old, and I can't update it because the newer versions don't support my system.

EDIT: Looks like I can update to XCode 4.6. I'm going to try that and see if it helps.

EDIT2: Looks like that works (only have linker errors for my own stuff now, but that's easily fixed). I guess you can close this, then!

@philsquared
Copy link
Collaborator

Thanks. I'll close this issue as it is resolved for you. I might still try and avoid the self-referential nature of TrackedSection, though.
Thanks for bringing it up.

@vadz
Copy link
Contributor

vadz commented Sep 7, 2015

FWIW I just ran into the same problem with CATCH 1.2.1 while compiling something using 10.8 SDK (for compatibility with OS X 10.7). This does look like a bug in compiler (mine is even older, it's Apple clang version 4.1 (tags/Apple/clang-421.11.66) (based on LLVM 3.1svn)), but I'm not completely sure.

Notice that this only happens if -std=c++11 is used, without it everything is fine (whether using -stdlib=libc++ or not).

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

4 participants