Skip to content

Fix type conversion errors in case of TizenRT. #2572

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

Merged

Conversation

rtakacs
Copy link
Contributor

@rtakacs rtakacs commented Oct 26, 2018

There are some conversion errors when building JerryScript for TizenRT. This patch fixes that.

E.g.

error: conversion to '_Bool8' from 'int' may alter its value [-Werror=conversion]
    return_with_literal &= !PARSER_IS_CLASS_CONSTRUCTOR_SUPER (context_p->status_flags);

JerryScript-DCO-1.0-Signed-off-by: Roland Takacs [email protected]
Copy link
Member

@rerobika rerobika left a comment

Choose a reason for hiding this comment

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

LGTM (informal)

Copy link
Member

@zherczeg zherczeg left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@LaszloLango LaszloLango left a comment

Choose a reason for hiding this comment

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

LGTM

@LaszloLango LaszloLango merged commit ffbd6e6 into jerryscript-project:master Oct 26, 2018
Copy link
Member

@akosthekiss akosthekiss left a comment

Choose a reason for hiding this comment

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

Wouldn't an explicit type cast to bool be a better approach in these cases? almost_bool ? true : false seem strange to me.

A related question: Travis CI is green. Where does the error manifest itself?

@rtakacs
Copy link
Contributor Author

rtakacs commented Oct 26, 2018

@akosthekiss There are other ? true : false places in the code and I use that solution for the hotfix. The explicit type conversion indeed looks better.
The conversion errors are found by JSRemoteTest (when building for TizenRT). It is interesting why JerryScript's Travis jobs could not catch these errors.

@zherczeg
Copy link
Member

http://port70.net/~nsz/c/c11/n1570.html#6.3.1.2
This should be followed by C compilers. If a compiler complains, it does not follow the standard, so we should be careful.

@akosthekiss
Copy link
Member

The referred section of the standard only mandates how a value must be converted to bool, not when. I.e., the standard does not require the compiler to allow implicit conversion from int to bool.

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.

5 participants