By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,194 Members | 884 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,194 IT Pros & Developers. It's quick & easy.

"Undefined Behaviour" or "Non-portable"

P: n/a
Would you classify the following code as "Undefined Behaviour" or as "Non-
portable"?

signed main()
{
signed char chedder = 130;
}
Relevant information:

1) Minimum range for a signed char: -127 to 127
2) Overflow for a signed integral type is Undefined Behaviour
3) There's no maximum range for a signed char

If the program is run on a system with a 9-Bit char, then there's no
overflow, and as such there's no Undefined Behaviour.

But overall would you classify it as "Undefined Behaviour" or "Non-
portable"?
-JKop


-JKop
Jul 22 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"JKop" <NU**@NULL.NULL> wrote in message
news:On******************@news.indigo.ie...
Would you classify the following code as "Undefined Behaviour" or as "Non-
portable"?

signed main()
{
signed char chedder = 130;
}
Relevant information:

1) Minimum range for a signed char: -127 to 127
2) Overflow for a signed integral type is Undefined Behaviour
3) There's no maximum range for a signed char

If the program is run on a system with a 9-Bit char, then there's no
overflow, and as such there's no Undefined Behaviour.

But overall would you classify it as "Undefined Behaviour" or "Non-
portable"?


Implementation-defined. If the range of signed char does not include 130,
then the result of assigning 130 to a signed char variable is
implementation-defined, which means that the implementation is required to
document its actual behavior.
Jul 22 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.