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

[basic.fundamental]p4 misquotes C #3310

Closed
AaronBallman opened this issue Oct 21, 2019 · 7 comments · Fixed by #3640
Closed

[basic.fundamental]p4 misquotes C #3310

AaronBallman opened this issue Oct 21, 2019 · 7 comments · Fixed by #3640
Assignees

Comments

@AaronBallman
Copy link
Contributor

The note in [basic.fundamental]p4 (http://eel.is/c++draft/basic.fundamental#4.sentence-5) is incorrect if it's relying on the C standard to provide that guarantee. The C standard states that padding bits can cause trap representations. See C17 footnote 53:

Some combinations of padding bits might generate trap representations, for example, if one padding bit is a parity bit. Regardless, no arithmetic operation on valid values can generate a trap representation other than as part of an exceptional condition such as an overflow, and this cannot occur with unsigned types. All other combinations of padding bits are alternative object representations of the value specified by the value bits.

@zygoloid
Copy link
Member

zygoloid commented Nov 3, 2019

The C++ specification generally does not rely on the C core language specification. (The C standard library is incorporated by reference, but the C++ core language specification is standalone.) The purpose of this reference to C is to point out the intentional difference between the two languages. This should be clarified if it's causing confusion.

@AaronBallman
Copy link
Contributor Author

I think it is a bit confusing -- it reads a bit like "padding bits cannot have traps, see C for rationale". Maybe it could be clarified with:

[ Note: Padding bits have unspecified value, but do not cause traps. See also <ins><xref>Annex C</xfref> and </ins>ISO C 6.2.6.2. — end note ]

and add a compatibility entry to Annex C.1 since this is a difference in behaviors between the two languages?

@jwakely
Copy link
Member

jwakely commented Nov 6, 2019

He did, he said [basic.fundamental]p4.

@jensmaurer
Copy link
Member

@AaronBallman, Annex C.1 lists situations where a valid C program may change semantics or be ill-formed when compiled as C++. The situation here is not such a case, since we are changing from trap (undefined behavior) to well-defined behavior.

@jensmaurer
Copy link
Member

jensmaurer commented Dec 8, 2019

We currently say

[Note: Padding bits have unspecified value, but do not cause traps. See also ISO C 6.2.6.2. -- end note]

Should we instead say "In contrast, see ISO C 6.2.6.2." ?

@jensmaurer jensmaurer added the decision-required A decision of the editorial group (or the Project Editor) is required. label Dec 8, 2019
@AaronBallman
Copy link
Contributor Author

@AaronBallman, Annex C.1 lists situations where a valid C program may change semantics or be ill-formed when compiled as C++. The situation here is not such a case, since we are changing from trap (undefined behavior) to well-defined behavior.

Okay, that's a fair point.

Should we instead say "In contrast, see ISO C 6.2.6.2." ?

That would clarify it for me, yes.

@jensmaurer jensmaurer self-assigned this Jan 17, 2020
@jensmaurer jensmaurer removed the decision-required A decision of the editorial group (or the Project Editor) is required. label Jan 17, 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 a pull request may close this issue.

5 participants
@zygoloid @jwakely @AaronBallman @jensmaurer and others