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

Fix build in GCC 7 #1407

Closed
wants to merge 1 commit into from
Closed

Conversation

brgl
Copy link

@brgl brgl commented Oct 11, 2018

The following error is emitted by gcc 7.3:

include/internal/catch_tostring.cpp:217:21: error: comparison is always true due to limited range of data type [-Werror=type-limits]
| } else if ('\0' <= value && value < ' ') {
| ~~~~~^~~~~~~~
| cc1plus: all warnings being treated as errors

We can drop the first part of the if since '\0' == 0 and it will always
be <= than value of char (which is unsigned by default).

Signed-off-by: Bartosz Golaszewski bgolaszewski@baylibre.com

Description

GitHub Issues

The following error is emitted by gcc 7.3:

include/internal/catch_tostring.cpp:217:21: error: comparison is always true due to limited range of data type [-Werror=type-limits]
|      } else if ('\0' <= value && value < ' ') {
|                 ~~~~~^~~~~~~~
| cc1plus: all warnings being treated as errors

We can drop the first part of the if since '\0' == 0 and it will always
be <= than value of char (which is unsigned by default).

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
@mgaio
Copy link
Contributor

mgaio commented Oct 11, 2018

The PR #1399 fix is related to this PR.
But issue observed is not related to compiler but to ARM target.

@@ -214,7 +214,7 @@ std::string StringMaker<char>::convert(char value) {
return "'\\n'";
} else if (value == '\t') {
return "'\\t'";
} else if ('\0' <= value && value < ' ') {
} else if (value < ' ') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changes the semantics, whether char is signed is implementation defined. In some platforms their ABI may indicate char is unsigned, some others signed: In Visual C++ char is signed by default, in GCC unsigned...
I think the fix is to use this instead:
if(unsigned(value) < ' ')

@horenmar
Copy link
Member

Thanks, but I merged #1399 instead.

@horenmar horenmar closed this Oct 13, 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

Successfully merging this pull request may close these issues.

4 participants