D
Dan Pop
In said:I'm starting from the premise that
printf("a = %hu", a);
is defined behavior for the case in question,
Where does the standard say that?
Dan
In said:I'm starting from the premise that
printf("a = %hu", a);
is defined behavior for the case in question,
Dan said:Where does the standard say that?
In said:The standard doesn't actually refer to
an unsigned short variable named "a".
Are you sure? Unless it is UB (of which I'm not sure), it should output
a = 65
Johnny said:[...] what does UB stand for and mean?
Johnny said:Please forgive my stupidity. But what does UB stand for and mean?
UB is "undefined behaviour", like writing to an uninitialised pointer.Johnny said:Please forgive my stupidity. But what does UB stand for and mean?
In said:Johnny said:[...] what does UB stand for and mean?
UB means "undefined behaviour",
Richard Heathfield said:Johnny said:[...] what does UB stand for and mean?
UB means "undefined behaviour", and refers to code whose result is not laid
down by the C standard. Examples include void main, fflush(stdin),
gets(NULL), and a trillion other examples of bad programming.
Minti said:Richard Heathfield said:Johnny said:[...] what does UB stand for and mean?
UB means "undefined behaviour", and refers to code whose result is not
laid down by the C standard. Examples include void main, fflush(stdin),
gets(NULL), and a trillion other examples of bad programming.
Just a curious, irrelevant question, if there are trillion examples of
bad programming, how many examples are there of good programming.
Certainly not a trillion.
Dan said:In <bo0m6p$crp$1@titan.btinternet.com> Richard Heathfield
Johnny said:[...] what does UB stand for and mean?
UB means "undefined behaviour",
How do you know? What is preventing UB from meaning "unspecified
behaviour", which, in the context of the C standard, is a completely
different beast?
Because of this ambiguity, UB should be avoided, unless the context
provides enough information for disambiguation.
In said:Dan said:In <bo0m6p$crp$1@titan.btinternet.com> Richard Heathfield
Johnny wrote:
[...] what does UB stand for and mean?
UB means "undefined behaviour",
How do you know? What is preventing UB from meaning "unspecified
behaviour", which, in the context of the C standard, is a completely
different beast?
Nothing, which is why I suggested the alternatives UDB and USB, some time
ago.
In message <3DC78EAC.360E5936@eton.powernet.co.uk> I said: "Others in
this newsgroup call undefined behaviour "UB", but there is nothing to
disambiguate that from "unspecified behaviour", so I think it a poor
abbreviation. UDB and USB, *within the context of this newsgroup*, are not
ambiguous."
UB should /always/ be avoided.
Richard Heathfield said:Minti said:Richard Heathfield said:Johnny wrote:
[...] what does UB stand for and mean?
UB means "undefined behaviour", and refers to code whose result is not
laid down by the C standard. Examples include void main, fflush(stdin),
gets(NULL), and a trillion other examples of bad programming.
Just a curious, irrelevant question, if there are trillion examples of
bad programming, how many examples are there of good programming.
Certainly not a trillion.
It's trivial to write code to generate a trillion examples of good
programming.
Might take up a fair bit of storage, though.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.