Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8198183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:53:52+00:00 2026-06-07T05:53:52+00:00

1) I have read many times about undefined behavior in C. That is about

  • 0

1) I have read many times about undefined behavior in C. That is about : some behavior that C doesn’t say in its definition, so each compiler will have their implementation but not violate C standard. Example are : x= ++y*4 + ++y*3.

But, anyone here can give me two compiler that give different result ? I feel interested to test with it. (in my machine, I just have mingw)

2) And, C doesn’t say about order of + - * / operation. For example : 1*2 + 3 + 4*5. * / will be calculate first, but we don’t know its other.

So according to below example : if we have :

int a, b, c; 
// assign value for a,b,c
float result = a*b/c; // wrong
float result = (float)a*b/c; // seem true

But, b/c still can be calculate first, so the answer will be wrong. so, the true type-cast should be:

float result = a*b/(float)c

But, nearly, all books about C, all people coding C, always use : (float)a*b/c . Is it ALWAYS true, or they trust “normal compiler` will solve from left to right like we often think ?

Please give me clearer about this point.

Thanks 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T05:53:53+00:00Added an answer on June 7, 2026 at 5:53 am

    For 1) your are mixing up undefined behavior and unspecified behavior, they are not the same.
    This ugly expression that you give has undefined behavior; what you think are the consequences of undefined behavior is just unspecific behavior, namely that compilers chose one of different possibilities, which often is something that you can live with.

    Undefined behavior can be much worse. If the behavior is undefined the compiler can generally chose anything to its liking, eat your lunch, empty your bank account, crash your computer. And unfortunately there are situations where compilers will do bad things that you don’t expect in these cases. So just don’t provoke UB in the first place.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have read so many times, here and everywhere on the net, that mutexes
I have read about DFS and BFS many times but I have this doubt
I have a xml file that needs to be read from many many times.
I know that this has been talked about many times here, and I have
I have read many questions about Android, J2ME and RecordStore , but I still
I have read many questions about the facebook login but until not I didnt
I have read in many places that WPF combo does not support autocomplete but
Alright...I've given the site a fair search and have read over many posts about
Read the edit below for more information. I have some code below that I
I have been reading about model inheritances in django and have found that many

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.