Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to Software Development on Codidact!

Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.

Comments on Cast uninitialized variable to (void)

Post

Cast uninitialized variable to (void)

+3
−0

Is it undefined behaviour to cast an uninitialized variable to (void)?

Example:

int main()
{
  int x;
  (void)x;
  return 0;
}
History
Why does this post require moderator attention?
You might want to add some details to your flag.
Why should this post be closed?

2 comment threads

What are you trying to achieve? (3 comments)
I wonder if I should also tag this C++ also. The answer *might* be different for these different lang... (3 comments)
I wonder if I should also tag this C++ also. The answer *might* be different for these different lang...
Estela‭ wrote over 1 year ago

I wonder if I should also tag this C++ also. The answer might be different for these different languages. But the question is going to be exactly the same.

Canina‭ wrote over 1 year ago · edited over 1 year ago

Estela‭ C and C++ are two distinct languages that happen to use partly similar syntax, in no small part due to a shared history. My firm opinion is that, despite the common usage of "C/C++" and that the two sometimes have very similar semantics, they should not be casually lumped together any more than, say, C++ and C# should be casually lumped together just because they share syntactic elements and at times even semantics.

Estela‭ wrote over 1 year ago

Indeed they are distinct. Different is the word I used. The common "Do you know C/C++?" question is way missguided. They are however way closer than C++ and C#. The similarity goes beyond sometimes having similar semantics. The C++ language standard specification references the C specification. See section "1 Scope" of the C++ standard. The C++ standard also states "With the qualifications noted in Clause 17 through Clause 32 and in C.6, the C standard library is a subset of the C++ standard library". So, with those qualifications, knowledge of parts of the C standard is relevant for C++. The opposite is not true though, the C standard does not reference the C++ standard. So I was not casually lumping them together. However, the opposition to C++ tag I was expecting is happening. So I will refrain from that.