Morwenn / cpp-sort

Sorting algorithms & related tools for C++14
MIT License
624 stars 58 forks source link

Error messages are unreadable #28

Open Morwenn opened 9 years ago

Morwenn commented 9 years ago

In its current state, the library produces rather unreadable error messages and can spawn several hundreds of lines of cryptic error messages for a simple missing const without a single hint to what may be wrong. Honestly, this is a major drawback and the crazy amount of SFINAE insanity doesn't help.

We can't realistically put static assertions all over the place because many mechanisms in the library rely on SFINAE. There may be other ways to handle errors.


Some elements of answer:

To be honest the errors occuring when a const is missing are the worst kind. There might be ways to require less const everywhere while still providing it when needed.


A few resources about getting better error messages:

vendethiel commented 9 years ago

(unreadable*. here, did that help?)

Morwenn commented 9 years ago

@vendethiel Haha, it was more along the lines of « we want readable error messages », but you're right, I will change the title :p

vendethiel commented 9 years ago

:D sorry, I'm terrible at C++. Just ask my coworkers ;)

Morwenn commented 8 years ago

Apparently, some tricks exist to display better error messages upon SFINAE failure. I can probably check whether some of them could be used to improve cpp-sort's error messages too.

vendethiel commented 8 years ago

have you looked at the sqlpp guy's talk?

Morwenn commented 8 years ago

Yes I have (well, I have read the slides). The « strong typedef via inheritance » as well as the mention of concepts come from here. It's even possible that I opened this issue because of the talk actually.

vendethiel commented 8 years ago

that makes sense 👍

Morwenn commented 4 years ago

Two small changes that could reduce the compiler call stack in error messages:

Those little functions are used everywhere in the code base, don't offer much outside of sufficiently generic contexts and make can make calls stacks grow. Moreover it's easier to track the origin of a problem directly when (it2 - it1) appears directly in the algorithm rather than in the implementation of std::distance.

EDIT: done in commit 5c6d89a37f86edae7ce9172c61cc7f27e8a6f3c6