469,953 Members | 2,453 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,953 developers. It's quick & easy.

"Undefined Behaviour" or "Non-portable"

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
1 1876
"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.

Similar topics

3 posts views Thread by Tjerk Wolterink | last post: by
4 posts views Thread by J. Campbell | last post: by
3 posts views Thread by Steven T. Hatton | last post: by
3 posts views Thread by Mark Sullivan | last post: by
49 posts views Thread by matty | last post: by
9 posts views Thread by Klaus Johannes Rusch | last post: by
23 posts views Thread by Saizan | last post: by
5 posts views Thread by Pseudonyme | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.