POV-Ray : Newsgroups : povray.programming : HF height: bug report : Re: HF height: bug report Server Time
6 Oct 2024 10:55:14 EDT (-0400)
  Re: HF height: bug report  
From: Thorsten Froehlich
Date: 5 Aug 2001 12:57:38
Message: <3b6d7b02@news.povray.org>
In article <3b6d6d58@news.povray.org> , "Vadim Sytnikov" <syt### [at] rucom>
wrote:

> Yes, definitely. Although it's legal, it is implementation-defined

Exactly that is my point.  It isn't the business of the compiler to lecture
the programmer about the language definition in such a case.  It is clearly
specified as resulting in an implementation defined integer constant.  This
is a well-defined behavior and if the programmer isn't aware of it, i.e. by
doing a comparison like 'abcd' > 1234 it is at least very bad style (nearly
programming error).  However, declaring i.e. an enumeration with
multicharacter constants is fine, after all comparing an enumeration value
against an integer constant is bad style.

So why should a compiler issue a warning about something that is absolutely
legal?  Well, the simple answer is that it should shut up by default and
assume the programmer knows the standard.  A compiler should not assume an
incompetent programmer by default - and a multicharacter constant can hardly
be considered accidental.  Or should a compiler warn i.e. in a case like
"int i = 01;" because the programmer might have meant to write "0"?  If i
write a multicharacter constant I mean it, and it is a perfectly legal
program on every platform, thus the compiler does no need to "comment" it.

> That's especially important for POV-Ray. Just imagine porting code with
> that constant to, say, ancient Honeywell Bull with 36-bit chars...

So because some stoneage non-standard hardware and software it has to be on
on every 32 and 64 bit processor?   I like that ... after all there is
nothing wrong with a character constant on a 36 bit system.  Of course it
would be different if the resulting value would not _fit_ into an "int".
But obviously a four character constant fits will into a "int" on every 32+
bit system.  On a system with 16 bit "int"s it would of course be
appropriate if the compiler would issue an error (or warning) if a constant
is out of range!

On the other hand, to force the programmer to use tricks to get the compiler
to shut up is far more dangerous and leads to bloated and unreadable code.
The programmer is the master of the compiler*, not the other way around!!!

    Thorsten

* IMO, very ambiguous code should be considered an error and there would be
no default warnings at all in a really good C/C++ compiler.  Of course, a
well-specified and implemented language would not have such problems in the
first place <sigh>

____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde

Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.