Does the aliasing loophole apply to signed characters?What are the differences between a pointer variable and a reference variable in C++?What does the explicit keyword mean?When to use reinterpret_cast?How do I use arrays in C++?C++11 introduced a standardized memory model. What does it mean? And how is it going to affect C++ programming?Image Processing: Algorithm Improvement for 'Coca-Cola Can' RecognitionEfficient unsigned-to-signed cast avoiding implementation-defined behaviorReplacing a 32-bit loop counter with 64-bit introduces crazy performance deviationsHas a std::byte pointer the same aliasing implications as char*?Does the C++ standard allow for an uninitialized bool to crash a program?
How would a low-tech device be able to alert its user?
What stops you from using fixed income in developing countries?
Can you board the plane when your passport is valid less than 3 months?
How is linear momentum conserved in case of a freely falling body?
50-move rule: only the last 50 or any consecutive 50?
Are game port joystick button circuits more than plain switches? Is this one just faulty?
Can Orcus use Multiattack with any melee weapon?
Convergence of series of normally distributed random variables
Light Themed Cryptic
Does EU 261/2004 compensation apply if delayed by the border check?
Why error propagation in CBC mode encryption affect two blocks?
Why is proof-of-work required in Bitcoin?
Did anybody find out it was Anakin who blew up the command center?
How many lines of code does the original TeX contain?
What is the loud noise of a helicopter when the rotors are not yet moving?
Can I get a PhD for developing an educational software?
Breaker Mapping Questions
What should come first—characters or plot?
Joining lists with same elements
How were medieval castles built in swamps or marshes without draining them?
Make utility using LINQ
Can an ISO file damage—or infect—the machine it's being burned on?
Changing JPEG to RAW to use on Lightroom?
Is the negative potential of 書く used in this sentence and what is its meaning?
Does the aliasing loophole apply to signed characters?
What are the differences between a pointer variable and a reference variable in C++?What does the explicit keyword mean?When to use reinterpret_cast?How do I use arrays in C++?C++11 introduced a standardized memory model. What does it mean? And how is it going to affect C++ programming?Image Processing: Algorithm Improvement for 'Coca-Cola Can' RecognitionEfficient unsigned-to-signed cast avoiding implementation-defined behaviorReplacing a 32-bit loop counter with 64-bit introduces crazy performance deviationsHas a std::byte pointer the same aliasing implications as char*?Does the C++ standard allow for an uninitialized bool to crash a program?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
In C++ there is an aliasing loophole which allows the object representation of any object to be read or written through some pointers of character type.
Does this apply only to char
and unsigned char
or also to signed char
?
c++ language-lawyer
add a comment |
In C++ there is an aliasing loophole which allows the object representation of any object to be read or written through some pointers of character type.
Does this apply only to char
and unsigned char
or also to signed char
?
c++ language-lawyer
add a comment |
In C++ there is an aliasing loophole which allows the object representation of any object to be read or written through some pointers of character type.
Does this apply only to char
and unsigned char
or also to signed char
?
c++ language-lawyer
In C++ there is an aliasing loophole which allows the object representation of any object to be read or written through some pointers of character type.
Does this apply only to char
and unsigned char
or also to signed char
?
c++ language-lawyer
c++ language-lawyer
edited 8 hours ago
StoryTeller
118k18 gold badges253 silver badges320 bronze badges
118k18 gold badges253 silver badges320 bronze badges
asked 8 hours ago
BeeOnRopeBeeOnRope
29.5k9 gold badges97 silver badges199 bronze badges
29.5k9 gold badges97 silver badges199 bronze badges
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
No, the provision does not extend to signed char
.
[basic.lval]
8 If a program attempts to access the stored value of an object
through a glvalue of other than one of the following types the
behavior is undefined:
- [...]
- a
char
,unsigned char
, orstd::byte
type.
The quote above contains the very last bullet that pertains to aliasing with character types. signed char
is excluded.
Nevertheless, this is also part of the subject CWG Issue 350 deals with, and so may change. Given the direction the issue has taken, the intent is for it to be (eventually, hopefully?) well-defined.
That's quite interesting. Why ischar
allowed, which is signed on my machine, but notsigned char
? But that's probably the reason why they want to add it in an upcoming standard.
– mch
8 hours ago
@mch - Could be an editorial mistake. I can only guess, really.
– StoryTeller
8 hours ago
3
@mch It's because in some cases, the standard does not allowchar
to be signed. For example, trap representations are allowed in all signed types, so asigned char
may not be able to represent every byte, andchar
would have to be unsigned.
– Artyer
6 hours ago
2
@Artyer - Can't believe I forgot that. Though it's worth noting that with C++20 moving towards "2's complement only",signed char
no longer has place for trap values eel.is/c++draft/basic.fundamental#7.
– StoryTeller
6 hours ago
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f57653869%2fdoes-the-aliasing-loophole-apply-to-signed-characters%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
No, the provision does not extend to signed char
.
[basic.lval]
8 If a program attempts to access the stored value of an object
through a glvalue of other than one of the following types the
behavior is undefined:
- [...]
- a
char
,unsigned char
, orstd::byte
type.
The quote above contains the very last bullet that pertains to aliasing with character types. signed char
is excluded.
Nevertheless, this is also part of the subject CWG Issue 350 deals with, and so may change. Given the direction the issue has taken, the intent is for it to be (eventually, hopefully?) well-defined.
That's quite interesting. Why ischar
allowed, which is signed on my machine, but notsigned char
? But that's probably the reason why they want to add it in an upcoming standard.
– mch
8 hours ago
@mch - Could be an editorial mistake. I can only guess, really.
– StoryTeller
8 hours ago
3
@mch It's because in some cases, the standard does not allowchar
to be signed. For example, trap representations are allowed in all signed types, so asigned char
may not be able to represent every byte, andchar
would have to be unsigned.
– Artyer
6 hours ago
2
@Artyer - Can't believe I forgot that. Though it's worth noting that with C++20 moving towards "2's complement only",signed char
no longer has place for trap values eel.is/c++draft/basic.fundamental#7.
– StoryTeller
6 hours ago
add a comment |
No, the provision does not extend to signed char
.
[basic.lval]
8 If a program attempts to access the stored value of an object
through a glvalue of other than one of the following types the
behavior is undefined:
- [...]
- a
char
,unsigned char
, orstd::byte
type.
The quote above contains the very last bullet that pertains to aliasing with character types. signed char
is excluded.
Nevertheless, this is also part of the subject CWG Issue 350 deals with, and so may change. Given the direction the issue has taken, the intent is for it to be (eventually, hopefully?) well-defined.
That's quite interesting. Why ischar
allowed, which is signed on my machine, but notsigned char
? But that's probably the reason why they want to add it in an upcoming standard.
– mch
8 hours ago
@mch - Could be an editorial mistake. I can only guess, really.
– StoryTeller
8 hours ago
3
@mch It's because in some cases, the standard does not allowchar
to be signed. For example, trap representations are allowed in all signed types, so asigned char
may not be able to represent every byte, andchar
would have to be unsigned.
– Artyer
6 hours ago
2
@Artyer - Can't believe I forgot that. Though it's worth noting that with C++20 moving towards "2's complement only",signed char
no longer has place for trap values eel.is/c++draft/basic.fundamental#7.
– StoryTeller
6 hours ago
add a comment |
No, the provision does not extend to signed char
.
[basic.lval]
8 If a program attempts to access the stored value of an object
through a glvalue of other than one of the following types the
behavior is undefined:
- [...]
- a
char
,unsigned char
, orstd::byte
type.
The quote above contains the very last bullet that pertains to aliasing with character types. signed char
is excluded.
Nevertheless, this is also part of the subject CWG Issue 350 deals with, and so may change. Given the direction the issue has taken, the intent is for it to be (eventually, hopefully?) well-defined.
No, the provision does not extend to signed char
.
[basic.lval]
8 If a program attempts to access the stored value of an object
through a glvalue of other than one of the following types the
behavior is undefined:
- [...]
- a
char
,unsigned char
, orstd::byte
type.
The quote above contains the very last bullet that pertains to aliasing with character types. signed char
is excluded.
Nevertheless, this is also part of the subject CWG Issue 350 deals with, and so may change. Given the direction the issue has taken, the intent is for it to be (eventually, hopefully?) well-defined.
edited 8 hours ago
answered 8 hours ago
StoryTellerStoryTeller
118k18 gold badges253 silver badges320 bronze badges
118k18 gold badges253 silver badges320 bronze badges
That's quite interesting. Why ischar
allowed, which is signed on my machine, but notsigned char
? But that's probably the reason why they want to add it in an upcoming standard.
– mch
8 hours ago
@mch - Could be an editorial mistake. I can only guess, really.
– StoryTeller
8 hours ago
3
@mch It's because in some cases, the standard does not allowchar
to be signed. For example, trap representations are allowed in all signed types, so asigned char
may not be able to represent every byte, andchar
would have to be unsigned.
– Artyer
6 hours ago
2
@Artyer - Can't believe I forgot that. Though it's worth noting that with C++20 moving towards "2's complement only",signed char
no longer has place for trap values eel.is/c++draft/basic.fundamental#7.
– StoryTeller
6 hours ago
add a comment |
That's quite interesting. Why ischar
allowed, which is signed on my machine, but notsigned char
? But that's probably the reason why they want to add it in an upcoming standard.
– mch
8 hours ago
@mch - Could be an editorial mistake. I can only guess, really.
– StoryTeller
8 hours ago
3
@mch It's because in some cases, the standard does not allowchar
to be signed. For example, trap representations are allowed in all signed types, so asigned char
may not be able to represent every byte, andchar
would have to be unsigned.
– Artyer
6 hours ago
2
@Artyer - Can't believe I forgot that. Though it's worth noting that with C++20 moving towards "2's complement only",signed char
no longer has place for trap values eel.is/c++draft/basic.fundamental#7.
– StoryTeller
6 hours ago
That's quite interesting. Why is
char
allowed, which is signed on my machine, but not signed char
? But that's probably the reason why they want to add it in an upcoming standard.– mch
8 hours ago
That's quite interesting. Why is
char
allowed, which is signed on my machine, but not signed char
? But that's probably the reason why they want to add it in an upcoming standard.– mch
8 hours ago
@mch - Could be an editorial mistake. I can only guess, really.
– StoryTeller
8 hours ago
@mch - Could be an editorial mistake. I can only guess, really.
– StoryTeller
8 hours ago
3
3
@mch It's because in some cases, the standard does not allow
char
to be signed. For example, trap representations are allowed in all signed types, so a signed char
may not be able to represent every byte, and char
would have to be unsigned.– Artyer
6 hours ago
@mch It's because in some cases, the standard does not allow
char
to be signed. For example, trap representations are allowed in all signed types, so a signed char
may not be able to represent every byte, and char
would have to be unsigned.– Artyer
6 hours ago
2
2
@Artyer - Can't believe I forgot that. Though it's worth noting that with C++20 moving towards "2's complement only",
signed char
no longer has place for trap values eel.is/c++draft/basic.fundamental#7.– StoryTeller
6 hours ago
@Artyer - Can't believe I forgot that. Though it's worth noting that with C++20 moving towards "2's complement only",
signed char
no longer has place for trap values eel.is/c++draft/basic.fundamental#7.– StoryTeller
6 hours ago
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f57653869%2fdoes-the-aliasing-loophole-apply-to-signed-characters%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown