KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
When I today read the C Standard, it says about side effects Accessing a volatile object, modifying an object, modifying a file, or calling a function that does any of those operations are all side effects and the C++ Standard says Accessing an object designated by a volatile glvalue (3.10), modifying an object, calling a library I/O function, or calling a function that does any of those operations are all side effects Hence because both forbid unsequenced side effects to occur on the same scalar object, C allows the following, but C++ makes it undefined behavior int a = 0; volatile int *pa = &a; int b = *pa + *pa; Am I reading the specifications correctly? And what is the reason for the discrepancy, if so?
Tags (comma-separated)
Save Edits
Cancel