weird try and catch statement messing up my code...

Started by
19 comments, last by pag 20 years, 10 months ago
quote:Original post by afterburn
I believe that he is telling you just because your compiler does intialize the variable for you does not mean all compilers will.

No, that''s not what I''m saying. All correct compilers should initialise variables under the same circumstances, and I''d expect the problem given to always result in an uninitialised variable. What I''m saying is that any attempt to inspect an uninitialised variable results in undefined behaviour. I''m also pointing out that `undefined behaviour'' is not just a colloquial term, but a term that has a definition according to the C++ Standard, so it is not open to interpretation what it actually means. If a compiler chooses to implement this particular behaviour as `take the value represented by the bit-pattern at the uninitialised location and interpret it as a valid value'' then that will not violate the meaning of undefined behaviour. However, some platforms might choose to implement access to uninitialised variables by trapping the access. It is possible the uninitialised bit-pattern constitutes an invalid value for the type - the quote I gave earlier gives the example of an indeterminate boolean. The actual results of uninitialised variable access depend on the platform and compiler being used - which is why the Standard does not impose one particular behaviour, hence it is left `undefined''.
quote:Original post by fizban75
Sabre, why can''t you just discuss topics in a grown up manner, rather than attacking people?

I''m not attacking you. A lot of people on these forums - probably the majority - do not know what `undefined behaviour'' means. It is very common to see someone take the results of their (usually MS) compiler as being the definitive interpretation of how C++ works, while not realising they are actually witnessing just one valid interpretation of undefined behaviour. Your earlier response made me believe that was what you had done.
quote:
If you''d like to point out my errors in judgement and interpretation, so be it. I welcome it. But you don''t have to put down others in the process.

A put down would be something like `you idiot - you don''t even know what undefined behaviour is!''
quote:
I don''t believe that the code:

int i;
i++;

necessitates an lvalue-to-rvalue-conversion, but if you think otherwise, I''d like to hear your thoughts.

What I''m telling you is the semantics are those of an lvalue-to-rvalue conversion. What goes on under-the-hood is irrelevant to the semantics of the C++ Standard, and the question of whether the C++ Standard defines the results of the operation - it doesn''t.

This topic is closed to new replies.

Advertisement