Skip to content

[test] Explicitly sign chars to match expectations #1103

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

Closed

Conversation

modocache
Copy link
Contributor

char is not always signed by default. In fact, the signedness of the char datatype in C is undefined. That means that on some architectures, the c_layout.sil test fails, because it expects the IR for char chareth(char a); to use signedext, whereas some architectures treat these types as unsigned, and thus zeroext is used.

In order to ensure identical signedness on all platforms the tests run on, explicitly specify the signedness using the compiler flag -fsigned-char.


More information on char signedness can be found here: http://blog.cdleary.com/2012/11/arm-chars-are-unsigned-by-default/

I discovered this failure when targeting Android armv7. I've tested this change against Android armv7 and Linux x86_64.

@hpux735, I'm curious whether the test is currently failing for you on Linux armv6/armv7, and whether this change fixes things!

`char` is not always signed by default. In fact, the signedness of the `char`
datatype in C is undefined. That means that on some architectures, the
`c_layout.sil` test fails, because it expects the IR for
`char chareth(char a);` to use `signedext`, whereas some
architectures treat these types as unsigned, and thus `zeroext` is used.

In order to ensure identical signedness on all platforms the tests run
on, explicitly specify the signedness using the compiler flag
`-fsigned-char`.
@jckarter
Copy link
Contributor

It's probably better to fix the tests so that they test for the target platform's expected char signedness.

@modocache
Copy link
Contributor Author

Ah, good call. In that case, each of the Linux arm targets should probably include their own set of conditional tests. Android armv7 isn't ready to be reviewed yet, so I'll add a set of tests to that project and close this for now. Thanks!!

@modocache modocache closed this Jan 26, 2016
modocache added a commit to SwiftAndroid/swift that referenced this pull request Feb 9, 2016
`char` is not always signed by default. In fact, the signedness
of the `char` datatype in C is undefined. That means that on some
architectures, the `c_layout.sil` test fails, because it expects
the IR for `char chareth(char a);` to use `signedext`, whereas
some architectures treat these types as unsigned, and thus
`zeroext` is used.

In order to ensure identical signedness on all platforms the tests
run on, explicitly specify the signedness using the compiler flag
`-fsigned-char`.

It would be better to test the signedness for each platform, as
suggested in swiftlang#1103. This is an
interim solution.
modocache added a commit to SwiftAndroid/swift that referenced this pull request Feb 19, 2016
`char` is not always signed by default. In fact, the signedness
of the `char` datatype in C is undefined. That means that on some
architectures, the `c_layout.sil` test fails, because it expects
the IR for `char chareth(char a);` to use `signedext`, whereas
some architectures treat these types as unsigned, and thus
`zeroext` is used.

In order to ensure identical signedness on all platforms the tests
run on, explicitly specify the signedness using the compiler flag
`-fsigned-char`.

It would be better to test the signedness for each platform, as
suggested in swiftlang#1103. This is an
interim solution.
modocache added a commit to SwiftAndroid/swift that referenced this pull request Feb 22, 2016
`char` is not always signed by default. In fact, the signedness
of the `char` datatype in C is undefined. That means that on some
architectures, the `c_layout.sil` test fails, because it expects
the IR for `char chareth(char a);` to use `signedext`, whereas
some architectures treat these types as unsigned, and thus
`zeroext` is used.

In order to ensure identical signedness on all platforms the tests
run on, explicitly specify the signedness using the compiler flag
`-fsigned-char`.

It would be better to test the signedness for each platform, as
suggested in swiftlang#1103. This is an
interim solution.
modocache added a commit to SwiftAndroid/swift that referenced this pull request Feb 23, 2016
`char` is not always signed by default. In fact, the signedness
of the `char` datatype in C is undefined. That means that on some
architectures, the `c_layout.sil` test fails, because it expects
the IR for `char chareth(char a);` to use `signedext`, whereas
some architectures treat these types as unsigned, and thus
`zeroext` is used.

In order to ensure identical signedness on all platforms the tests
run on, explicitly specify the signedness using the compiler flag
`-fsigned-char`.

It would be better to test the signedness for each platform, as
suggested in swiftlang#1103. This is an
interim solution.
modocache added a commit to SwiftAndroid/swift that referenced this pull request Feb 25, 2016
`char` is not always signed by default. In fact, the signedness
of the `char` datatype in C is undefined. That means that on some
architectures, the `c_layout.sil` test fails, because it expects
the IR for `char chareth(char a);` to use `signedext`, whereas
some architectures treat these types as unsigned, and thus
`zeroext` is used.

In order to ensure identical signedness on all platforms the tests
run on, explicitly specify the signedness using the compiler flag
`-fsigned-char`.

It would be better to test the signedness for each platform, as
suggested in swiftlang#1103. This is an
interim solution.
MaxDesiatov pushed a commit to MaxDesiatov/swift that referenced this pull request Jun 5, 2020
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.

2 participants