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

Char arithmetic is undefined outside of the character set #484

Open
jdinan opened this issue Nov 1, 2021 · 0 comments
Open

Char arithmetic is undefined outside of the character set #484

jdinan opened this issue Nov 1, 2021 · 0 comments

Comments

@jdinan
Copy link
Collaborator

jdinan commented Nov 1, 2021

Problem Statement

We have character reductions in OpenSHMEM. However, the C language specification only guarantees well-defined behavior when the values correspond to characters in the basic execution character set.

C99 Section 6.2.5, Paragraph 3:

An object declared as type char is large enough to store any member of the basic execution character set. If a member of the basic execution character set is stored in a char object, its value is guaranteed to be positive. If any other character is stored in a char object, the resulting value is implementation-defined but shall be within the range of values that can be represented in that type.

Question

Should an OpenSHMEM reduction on character data provide be required to provide the implementation-defined result? For context, this was encountered recently because Power 9 treats character as unsigned whereas x86/Linux treats it as a signed type. ASCII is a 7-bit character set, so it is implementation defined what to do with the eighth bit.

Possible Solutions

  1. Specify whether OpenSHMEM libraries need to provide the C language's implementation defined behavior or can provide their own.
  2. Remove char reductions since we have uint8_t, signed char, and unsigned char.
  3. ??
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

1 participant