Hello fredvs,

you wrote on Sun, 15 Mar 2020 16:53:12 -0700 (MST):

> > What a glaring omission, no?   
> 
> Yes.

Thank you for your support.

> Also I am not totally convinced by the arguments to defend the choice of 0
> as initialization of a enum var.
> Imho, it would be much more logic to initialize with the first item and I
> do not see what could be the problems.

This "choice" is just an artefact of the way the runtime library prepares
the program's memory - it simply "clears" the whole area, i.e. it writes
zeroes all the way. There's _NO_ provision to make sure that this is in
any way useful or "legal".
But here seems to be anothe rproblem in fpc's implementation, when, as you
seem to have verified, the cast of a value that _may not have a binary
representation consisting of 0s_ is simply accepted for use in a program.
This is inconsistent, even dangerous, and at least misleading.

> Here the answer in fpc mailing-list

Thanks, I already read that by means of your links last time.
I won't comment on this, as the argumentation is, to say the least,
extremely weak.
Why don't they simply accept that a variable may be initialized by some
illegal value that way? There's no guarantee that _any_ variable will be
"initialized" to some useable value if it's a local variable, either.
Your local variable will get some arbitrary byte pattern from whatever used
the memory before, be it an enumeration, integer or floating point value.
Even when integers cannot have a really "illegal" value - all bit patterns
are allowed - there are many types where this is _not_ so, among them also
floating point values, which may be denormalized or even "NaN"s (Not a
Number"), which latter _may_ produce an exception or just an unexpected
result...
I think, it's better to get a warning than a crash, even if it's not a big
aircraft (like those recently...).

-- 
-- 
(Weitergabe von Adressdaten, Telefonnummern u.ä. ohne Zustimmung
nicht gestattet, ebenso Zusendung von Werbung oder ähnlichem)
-----------------------------------------------------------
Mit freundlichen Grüßen, S. Schicktanz
-----------------------------------------------------------




_______________________________________________
mseide-msegui-talk mailing list
mseide-msegui-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk

Reply via email to