Confusing compile error

P

Prateek R Karandikar

Jeff Relf said:
Hi Karl Heinz Buchegger,

You asked,
" Where in the C++ standard is it mentioned that
dividing by 0 does not trigger an exception with
release compiled code. "

For VC 6 release-complied code,
a floating point divide-by-zero simply returns an overflow.
Which can then simply be checked using _isnan( float ).

I just checked integers ... They will hang your code ...
forcing you to kill it.

Now, ignoring standards for just one moment,
which response do you think was better behaved ?

ignoring standards? the Standard is the very document that defines the
language, and Standard C++ is the topic of this group. If you choose
to ignore the Standard, then it becomes off-topic for this group.
A. The one that had to be killed by hand.
B. The one that simply returned an overflow,
and which could then be checked using _isnan( float ).

Take your time answering this question,
I know how hard it is for you.

Division by zero invokes undefined behaviour, so any behaviour is ok.
Efficiency is very important for C++. Option A would probably be more
efficient. Option B tests the second operand of operator/ (for the
inbuilt usages) for equality to zero, each time you divide. So it is
inefficient. If you are willing to check for overflow after the
division, why not simply check *before* the division whether the
second operand is zero or not? BTW, your scheme involves 2 checks: the
system checks once when you divide, and returns overflow on zero, and
then you check later for overflow. Instead, why not check just once
before the division?
After you answered that question,
I might answer your question
about IEEE floating point standards.

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
To iterate is human, to recurse divine.
-L. Peter Deutsch
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
K

Karl Heinz Buchegger

Jeff said:
Hi red floyd,

You said that your compiler,
' has no " compile for release " option. '

Why ? Is it the student version ?

Only the Pro version of VC 6 has the optimizer.

Did it ever come to your mind that there are more C++
compilers around then VC++ ?
 
K

Karl Heinz Buchegger

Jeff said:
Hi Karl Heinz Buchegger,

You asked,
" Where in the C++ standard is it mentioned that
dividing by 0 does not trigger an exception with
release compiled code. "

For VC 6 release-complied code,
a floating point divide-by-zero simply returns an overflow.
Which can then simply be checked using _isnan( float ).

I just checked integers ... They will hang your code ...
forcing you to kill it.

Now, ignoring standards for just one moment,
which response do you think was better behaved ?
A. The one that had to be killed by hand.
B. The one that simply returned an overflow,
and which could then be checked using _isnan( float ).

Take your time answering this question,
I know how hard it is for you.

Man. You are one of the worst cases of 'All the world is a VAX'
that happend to come to this group in the last time.

Read it character by character:

T h i s g r o u p d o e s * N O T * d e a l
w i t h a n y s p e c i f i c i m p l e m e n t a t i o n.

F o r t h i s g r o u p , t h e r e i s o n l y t h e
S t a n d a r d s d o c u m e n t r e l e v a n t .
W h a t y o u r s p e c i f i c i m p l e m e n t a t i o n
d o e s o r n o t d o e s , i s i r r e l e v a n t a s
l o n g a s t h e S t a n d a r d s d o c u m e n t d o e s n ' t
s a y i t h a s t o d o i t.


Got it now: No platform specifics in this group!
After you answered that question,
I might answer your question
about IEEE floating point standards.

Q: Where in the standard is it mentioned that IEEE has to be used
in C++ ?
A: Nowhere. So IEEE is irrelevant to this group.
 
A

Alf P. Steinbach

* Jeff Relf:
Hi Karl Heinz Buchegger,

You asked,
" Where in the C++ standard is it mentioned that
dividing by 0 does not trigger an exception with
release compiled code. "

For VC 6 release-complied code,
a floating point divide-by-zero simply returns an overflow.
Which can then simply be checked using _isnan( float ).

Try to use standard-conforming code to check for NaN. One simple way
is based on the fact that only NaN compares as unequal to itself.

I just checked integers ... They will hang your code ...
forcing you to kill it.

That is not mandated by the standard. What you have with integers is
undefined behavior. Anything could happen, depending on the phase of
the moon.

I might answer your question
about IEEE floating point standards.

You might find it educational to check out the standard's support for
IEEE floating point in std::numeric_limits.

If you static assert that floating point is IEEE (called "iec" in the
standard) and that floating point operations result in NaN's rather
than exceptions, and use standard-conforming code for checking for
NaN's, then your code can be standard-compliant; e.g., will also work
with other compilers that are standard-conforming in this respect, and
can be discussed in this group.
 
R

Richard Herring

In message <[email protected]>, Jeff Relf <[email protected]>
writes

[Do stop changing the subject, there's a good chap]
Hi red floyd,

You said that your compiler,
' has no " compile for release " option. '

Why ? Is it the student version ?

Only the Pro version of VC 6 has the optimizer.

"Compiler" is not synonymous with "VC6".
 
J

Jeff Relf

Hi Alf P. Steinbach,

Re: Your irritation over my
real world account of a floating point division by zero.

Earth to Steinbach. Earth to Steinbach.
Come in Steinbach. Are you there Steinbach ?

You Only care about standards ?
Generating NaN's instead of locking up
is probably the default behavior according to the standard.

If you think I'm wrong about that ...
and if it's getting under your skin,
Why don't you just prove me wrong ?

As for me, I don't care either way.
 
S

Steven T. Hatton

Jeff said:
Hi Alf P. Steinbach,
....
This is a person attack, and is thus inappropriate for this news group. If
you feel you must carry on this level of discourse, please take it to a
private channel.
 
R

Richard Herring

In message <[email protected]>, Jeff Relf

[Will you kindly stop changing the subject? If you're responding to an
earlier posting, keep it in the same thread. That means not changing
the subject line and using standard References: headers.
Otherwise users of non-threading newsreaders won't be able to make any
sense of your postings.]

Hi Alf P. Steinbach,

You pressed the wrong button. This is comp.lang.c++, not a private
mailbox.
Re: Your irritation over my
real world account of a floating point division by zero.

Earth to Steinbach. Earth to Steinbach.
Come in Steinbach. Are you there Steinbach ?

You Only care about standards ?
Generating NaN's instead of locking up
is probably the default behavior according to the standard.

According to the standard it's undefined behaviour. End. Of. Story.
If you think I'm wrong about that ...
and if it's getting under your skin,
Why don't you just prove me wrong ?

ISO/IEC Standard 14882, section 5.5:

"If during the evaluation of an expression, the result is not
mathematically defined or not in the range of representable values for
its type, the behavior is undefined..."

There is no requirement for NaNs to even exist.
As for me, I don't care either way.
So why do you keep posting, troll?
 
J

Jeff Relf

You wrote,
' ISO/IEC Standard 14882, section 5.5:
" If during the evaluation of an expression,
the result is not mathematically defined
or not in the range of representable values
for its type, the behavior is undefined..."
There is no requirement for NaNs to even exist. '

Riiiiiiiiight,
as if such a standard would not exist anywhere on the net,
so you can't provide a link. Suuuuure. Whatever you say.

As for the Subject: line in my headers,
People who aren't threading using the References: line
are lost causes anyways,
I'm not too worried about them.
( Yes, Google's threading is loony, I say )

What about my Reference:'s line ?
What's nonstandard about it ?

As for addressing the individual that I am replying to,
that adds a lot of clarity, I say.
Sure, it's an open letter, but so what ?
 
K

Karl Heinz Buchegger

Jeff said:
You wrote,
' ISO/IEC Standard 14882, section 5.5:
" If during the evaluation of an expression,
the result is not mathematically defined
or not in the range of representable values
for its type, the behavior is undefined..."
There is no requirement for NaNs to even exist. '

Riiiiiiiiight,
as if such a standard would not exist anywhere on the net,
so you can't provide a link. Suuuuure. Whatever you say.

http://webstore.ansi.org/ansidocstore/product.asp?sku=ISO/IEC+14882:2003

Too lazy to google?
 
R

Richard Herring

Jeff Relf said:
You wrote,
' ISO/IEC Standard 14882, section 5.5:
" If during the evaluation of an expression,
the result is not mathematically defined
or not in the range of representable values
for its type, the behavior is undefined..."
There is no requirement for NaNs to even exist. '

Riiiiiiiiight,
as if such a standard would not exist anywhere on the net,
so you can't provide a link. Suuuuure. Whatever you say.
Right, whether you like it or not.

In their wisdom, the ISO require you to _pay_ for it. You may not like
it, I might not like it, but they own the copyright, so there's nothing
much we can do about it:

http://www.iso.ch/iso/en/CatalogueDetailPage.CatalogueDetail?CSNUMBER=381
10&ICS1=35

But you've already proclaimed that you're not interested in standards,
so why would you care?
As for the Subject: line in my headers,
People who aren't threading using the References: line
are lost causes anyways,
I'm not too worried about them.
( Yes, Google's threading is loony, I say )

What a strange way of categorising your fellow humans.
What about my Reference:'s line ?
What's nonstandard about it ?

It conflicts with your Subject: header.

RFC1036:
2.1.4. Subject

... If the message is submitted in
response to another message (e.g., is a follow-up) the default
subject should begin with the four characters "Re:", and the
"References" line is required...

2.2.5. References

This field lists the Message-ID's of any messages prompting the
submission of this message. It is required for all follow-up
messages, and forbidden when a new subject is raised...

And I _can_ provide a link to that:

http://www.faqs.org/rfcs/rfc1036.html
 
J

Jeff Relf

Hi Richard Herring,

Re: Threading.

No matter what any RFC might say,
No matter how f__ked up Google Groups might be,
The Subject: line has nothing to do with threading.
Threading is the sole responsibility of the References line.

That's not my opinion ... It's just the harsh reality.

Focusing too hard on fanciful standards
makes one blind to such realities.

Likewise,
it doesn't matter what that 300 dollar book of yours says,
NaN is the only appropriate response to a divide by zero.
And hanging is Never Ever the appropriate response.

If you had any paying clients, you'd already know that.

You can argue till the cows come home,
I won't change my mind.

And, Unless and until you show me an authoritative web link,
I'll continue to believe that NaN is the standard response.
 
J

Jeff Relf

Hi red floyd,

You commented, " PLOINK ! Oink. Oink. "

Comp.Lang.C++ blows.

I'm very proud of having absolutely no one ploinked.

Even back when I did ploink,
I still scored Absolutely All replies high.

I read all replies, no matter who they are.

Besides, Announcing Ploinks is just plain piggish.

Oink. Oink.
 
J

Jeff Relf

Hi Bill Seurer,

You commented,
" Some hardware
will throw an exception if you divide by zero
irregardless of any way you compiled your code. "

Microsoft Windows code, for PC's,
returns a NaN by default, when compiling for release.

I'm not targeting other platforms.

Cross-platform code is a very bad joke.
If you think your code will work, and work _ Well _ ,
no matter if it's running on a Mac G5 with a 40 inch TFT
or a cell phone ...

Then I have a bridge to sell you in Manhattan.
 
C

Claudio Puviani

Jeff Relf said:
Hi Bill Seurer,

You commented,
" Some hardware
will throw an exception if you divide by zero
irregardless of any way you compiled your code. "

Microsoft Windows code, for PC's,
returns a NaN by default, when compiling for release.

I'm not targeting other platforms.

Cross-platform code is a very bad joke.
If you think your code will work, and work _ Well _ ,
no matter if it's running on a Mac G5 with a 40 inch TFT
or a cell phone ...

Then I have a bridge to sell you in Manhattan.

Are you planning on growing up any time soon? Enough with the infantile antics
already.

Claudio Puviani
 
P

Phlip

Claudio said:
Jeff Relf wrote:

Are you planning on growing up any time soon? Enough with the infantile antics
already.

I wrote a program for PC and Linux, and tossed it on the 'net.

Googling for it later revealed a few people run it on the Sharp Zaurus PDA.

(It ain't in C++, though! ;-)

Most of the time, portability is for canoos. (Knowing how to be portable is
a sign of professionalism.) But after the first two platforms, the rest are
easier.
 
R

Richard Herring

Jeff Relf said:
Hi Richard Herring,

Re: Threading.

No matter what any RFC might say,

Your attitude to standards is already blindingly clear.
No matter how f__ked up Google Groups might be,

Who mentioned Google?
The Subject: line has nothing to do with threading.
Threading is the sole responsibility of the References line.

That's not my opinion ... It's just the harsh reality.

Focusing too hard on fanciful standards
makes one blind to such realities.

Likewise,
it doesn't matter what that 300 dollar book of yours says,

Wrong as usual. $18 online.
NaN is the only appropriate response to a divide by zero.

You've never heard of exceptions?
And hanging is Never Ever the appropriate response.

If you had any paying clients, you'd already know that.

No bite. My customer list is confidential.
You can argue till the cows come home,
I won't change my mind.

And, Unless and until you show me an authoritative web link,
I'll continue to believe that NaN is the standard response.
Believe what you like.
 

Ask a Question

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.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,062
Latest member
OrderKetozenseACV

Latest Threads

Top