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

Unsigned integer overflow in fileOrderComparator #151

Closed
martinfinke opened this issue Sep 10, 2018 · 3 comments
Closed

Unsigned integer overflow in fileOrderComparator #151

martinfinke opened this issue Sep 10, 2018 · 3 comments

Comments

@martinfinke
Copy link

Clang with -fsanitize=undefined shows this error message:

doctest.h:3635:45: runtime error: unsigned integer overflow: 84 - 280 cannot be represented in type 'unsigned int'

The code in question is:

static_cast<int>(lhs->m_line - rhs->m_line);

where m_line is of type unsigned.

@tbleher
Copy link
Contributor

tbleher commented Sep 11, 2018

Note that unsigned integer overflow is not undefined behavior (contrary to signed overflow, which is undefined), it is just flagged by Clang since it might indicate a bug.

@martinfinke martinfinke changed the title Undefined behavior in fileOrderComparator Unsigned integer overflow in fileOrderComparator Sep 12, 2018
@martinfinke
Copy link
Author

martinfinke commented Sep 12, 2018

Note that unsigned integer overflow is not undefined behavior (contrary to signed overflow, which is undefined), it is just flagged by Clang since it might indicate a bug.

Good point. I think it's a bug, as it's about ordering line numbers.

@onqtam
Copy link
Member

onqtam commented Sep 13, 2018

Thanks for reporting this!

I will check it after a month since I’m away right now - I have only a cell phone

@onqtam onqtam closed this as completed in 4af24f8 Nov 30, 2018
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

3 participants