* [Bug libstdc++/26020] std::advance() isn't stable for floating point numbers
2006-01-29 23:06 [Bug libstdc++/26020] New: std::advance() isn't stable for floating point numbers Woebbeking at web dot de
@ 2006-01-29 23:32 ` pinskia at gcc dot gnu dot org
2006-01-29 23:40 ` Woebbeking at web dot de
` (14 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-01-29 23:32 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pinskia at gcc dot gnu dot org 2006-01-29 23:32 -------
What does the standard says about this case?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26020
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug libstdc++/26020] std::advance() isn't stable for floating point numbers
2006-01-29 23:06 [Bug libstdc++/26020] New: std::advance() isn't stable for floating point numbers Woebbeking at web dot de
2006-01-29 23:32 ` [Bug libstdc++/26020] " pinskia at gcc dot gnu dot org
@ 2006-01-29 23:40 ` Woebbeking at web dot de
2006-01-30 0:24 ` pcarlini at suse dot de
` (13 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Woebbeking at web dot de @ 2006-01-29 23:40 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from Woebbeking at web dot de 2006-01-29 23:40 -------
Subject: Re: std::advance() isn't stable for floating point numbers
On Monday 30 January 2006 00:32, pinskia at gcc dot gnu dot org wrote:
> ------- Comment #1 from pinskia at gcc dot gnu dot org 2006-01-29
> 23:32 -------
> What does the standard says about this case?
Don't know, but I was suprised that Distance is a template parameter.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26020
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug libstdc++/26020] std::advance() isn't stable for floating point numbers
2006-01-29 23:06 [Bug libstdc++/26020] New: std::advance() isn't stable for floating point numbers Woebbeking at web dot de
2006-01-29 23:32 ` [Bug libstdc++/26020] " pinskia at gcc dot gnu dot org
2006-01-29 23:40 ` Woebbeking at web dot de
@ 2006-01-30 0:24 ` pcarlini at suse dot de
2006-01-30 0:35 ` gdr at integrable-solutions dot net
` (12 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: pcarlini at suse dot de @ 2006-01-30 0:24 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from pcarlini at suse dot de 2006-01-30 00:24 -------
AFAICS, the standard is silent about this issue. I think the suggested change
is correct.
--
pcarlini at suse dot de changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2006-01-30 00:24:19
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26020
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug libstdc++/26020] std::advance() isn't stable for floating point numbers
2006-01-29 23:06 [Bug libstdc++/26020] New: std::advance() isn't stable for floating point numbers Woebbeking at web dot de
` (2 preceding siblings ...)
2006-01-30 0:24 ` pcarlini at suse dot de
@ 2006-01-30 0:35 ` gdr at integrable-solutions dot net
2006-01-30 0:45 ` pcarlini at suse dot de
` (11 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: gdr at integrable-solutions dot net @ 2006-01-30 0:35 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from gdr at integrable-solutions dot net 2006-01-30 00:35 -------
Subject: Re: std::advance() isn't stable for floating point numbers
"pcarlini at suse dot de" <gcc-bugzilla@gcc.gnu.org> writes:
| AFAICS, the standard is silent about this issue. I think the suggested change
| is correct.
I believe Martin Sebor filled a related PR, whereby we should have
converted n to *some* integral type before proceeding...
-- Gaby
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26020
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug libstdc++/26020] std::advance() isn't stable for floating point numbers
2006-01-29 23:06 [Bug libstdc++/26020] New: std::advance() isn't stable for floating point numbers Woebbeking at web dot de
` (3 preceding siblings ...)
2006-01-30 0:35 ` gdr at integrable-solutions dot net
@ 2006-01-30 0:45 ` pcarlini at suse dot de
2006-01-30 0:57 ` pcarlini at suse dot de
` (10 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: pcarlini at suse dot de @ 2006-01-30 0:45 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from pcarlini at suse dot de 2006-01-30 00:45 -------
(In reply to comment #4)
> | AFAICS, the standard is silent about this issue. I think the suggested
> | change is correct.
>
> I believe Martin Sebor filled a related PR, whereby we should have
> converted n to *some* integral type before proceeding...
I was also under that impression. That issue, however, was about Size in algos,
which, at least, is required to be convertible to an integral type. I don't
think we even have such *minimal* requirement here... What do you suggest?
Should the LWG discuss such kind of requirements for Distance too? In the
meanwhile suspend? I have no strong opinions...
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26020
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug libstdc++/26020] std::advance() isn't stable for floating point numbers
2006-01-29 23:06 [Bug libstdc++/26020] New: std::advance() isn't stable for floating point numbers Woebbeking at web dot de
` (4 preceding siblings ...)
2006-01-30 0:45 ` pcarlini at suse dot de
@ 2006-01-30 0:57 ` pcarlini at suse dot de
2006-01-30 1:05 ` gdr at integrable-solutions dot net
` (9 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: pcarlini at suse dot de @ 2006-01-30 0:57 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from pcarlini at suse dot de 2006-01-30 00:57 -------
Hi again. On second tought, I don't think we have an issue here. Maybe of QoI
only, at most. The reason is that, according to 24.1/9, Distance is a
difference type in the "following sections". A bit vague, but that seem to
imply to also the template argument Distance in 24.3.4 is a difference type...
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26020
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug libstdc++/26020] std::advance() isn't stable for floating point numbers
2006-01-29 23:06 [Bug libstdc++/26020] New: std::advance() isn't stable for floating point numbers Woebbeking at web dot de
` (5 preceding siblings ...)
2006-01-30 0:57 ` pcarlini at suse dot de
@ 2006-01-30 1:05 ` gdr at integrable-solutions dot net
2006-01-30 1:07 ` gdr at integrable-solutions dot net
` (8 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: gdr at integrable-solutions dot net @ 2006-01-30 1:05 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from gdr at integrable-solutions dot net 2006-01-30 01:05 -------
Subject: Re: std::advance() isn't stable for floating point numbers
"pcarlini at suse dot de" <gcc-bugzilla@gcc.gnu.org> writes:
| ------- Comment #5 from pcarlini at suse dot de 2006-01-30 00:45 -------
| (In reply to comment #4)
| > | AFAICS, the standard is silent about this issue. I think the suggested
| > | change is correct.
| >
| > I believe Martin Sebor filled a related PR, whereby we should have
| > converted n to *some* integral type before proceeding...
|
| I was also under that impression. That issue, however, was about Size in
algos,
sorry; memory failing.
| which, at least, is required to be convertible to an integral type. I don't
| think we even have such *minimal* requirement here... What do you suggest?
reading the standard specification let me under the impression that
Distance is supposed to "related" to difference_type. For example
the distance between the p before and after calling distance(p, n) is
supposed to be n. So I would suggest conversion to the
difference_type of the iterator as a momentary resolution.
| Should the LWG discuss such kind of requirements for Distance too?
Definitely.
| In the meanwhile suspend? I have no strong opinions...
I'm not sure the resolution would introduce an ABI breakage, so I
would say let's do both; but I'm open to other alternatives.
-- Gaby
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26020
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug libstdc++/26020] std::advance() isn't stable for floating point numbers
2006-01-29 23:06 [Bug libstdc++/26020] New: std::advance() isn't stable for floating point numbers Woebbeking at web dot de
` (6 preceding siblings ...)
2006-01-30 1:05 ` gdr at integrable-solutions dot net
@ 2006-01-30 1:07 ` gdr at integrable-solutions dot net
2006-01-30 1:09 ` pcarlini at suse dot de
` (7 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: gdr at integrable-solutions dot net @ 2006-01-30 1:07 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from gdr at integrable-solutions dot net 2006-01-30 01:07 -------
Subject: Re: std::advance() isn't stable for floating point numbers
"pcarlini at suse dot de" <gcc-bugzilla@gcc.gnu.org> writes:
| Hi again. On second tought, I don't think we have an issue here. Maybe of QoI
| only, at most. The reason is that, according to 24.1/9, Distance is a
| difference type in the "following sections". A bit vague, but that seem to
| imply to also the template argument Distance in 24.3.4 is a difference
type...
That matches my interpretation --- hence Distance must behave "like"
an integral type -- but still, the question is exactly what kind of
relation does it have with say
std::iterator<FowardIterator>::difference_type.
-- Gaby
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26020
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug libstdc++/26020] std::advance() isn't stable for floating point numbers
2006-01-29 23:06 [Bug libstdc++/26020] New: std::advance() isn't stable for floating point numbers Woebbeking at web dot de
` (7 preceding siblings ...)
2006-01-30 1:07 ` gdr at integrable-solutions dot net
@ 2006-01-30 1:09 ` pcarlini at suse dot de
2006-01-30 7:08 ` Woebbeking at web dot de
` (6 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: pcarlini at suse dot de @ 2006-01-30 1:09 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from pcarlini at suse dot de 2006-01-30 01:09 -------
(In reply to comment #7)
> reading the standard specification let me under the impression that
> Distance is supposed to "related" to difference_type. For example
> the distance between the p before and after calling distance(p, n) is
> supposed to be n. So I would suggest conversion to the
> difference_type of the iterator as a momentary resolution.
Excellent idea.
> I'm not sure the resolution would introduce an ABI breakage, so I
> would say let's do both; but I'm open to other alternatives.
Agreed, let's implement your suggestion and send a note to the reflector (and
Martin, already working on the Size issue). Thanks!
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26020
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug libstdc++/26020] std::advance() isn't stable for floating point numbers
2006-01-29 23:06 [Bug libstdc++/26020] New: std::advance() isn't stable for floating point numbers Woebbeking at web dot de
` (8 preceding siblings ...)
2006-01-30 1:09 ` pcarlini at suse dot de
@ 2006-01-30 7:08 ` Woebbeking at web dot de
2006-01-30 7:54 ` gdr at integrable-solutions dot net
` (5 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Woebbeking at web dot de @ 2006-01-30 7:08 UTC (permalink / raw)
To: gcc-bugs
------- Comment #10 from Woebbeking at web dot de 2006-01-30 07:07 -------
Subject: Re: std::advance() isn't stable for floating point numbers
On Monday 30 January 2006 02:09, pcarlini at suse dot de wrote:
> ------- Comment #9 from pcarlini at suse dot de 2006-01-30 01:09
> ------- (In reply to comment #7)
>
> > reading the standard specification let me under the impression that
> > Distance is supposed to "related" to difference_type. For example
> > the distance between the p before and after calling distance(p, n)
> > is supposed to be n. So I would suggest conversion to the
> > difference_type of the iterator as a momentary resolution.
>
> Excellent idea.
FYI, I suggested tests for > 0 and < 0 as MSVC 7.1 does it that way.
If you convert Distance to difference_type the question is what happens
if Distance is i.e. 0.2. Do you advance by 0 or 1 position?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26020
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug libstdc++/26020] std::advance() isn't stable for floating point numbers
2006-01-29 23:06 [Bug libstdc++/26020] New: std::advance() isn't stable for floating point numbers Woebbeking at web dot de
` (9 preceding siblings ...)
2006-01-30 7:08 ` Woebbeking at web dot de
@ 2006-01-30 7:54 ` gdr at integrable-solutions dot net
2006-01-30 12:03 ` Woebbeking at web dot de
` (4 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: gdr at integrable-solutions dot net @ 2006-01-30 7:54 UTC (permalink / raw)
To: gcc-bugs
------- Comment #11 from gdr at integrable-solutions dot net 2006-01-30 07:54 -------
Subject: Re: std::advance() isn't stable for floating point numbers
"Woebbeking at web dot de" <gcc-bugzilla@gcc.gnu.org> writes:
| On Monday 30 January 2006 02:09, pcarlini at suse dot de wrote:
| > ------- Comment #9 from pcarlini at suse dot de 2006-01-30 01:09
| > ------- (In reply to comment #7)
| >
| > > reading the standard specification let me under the impression that
| > > Distance is supposed to "related" to difference_type. For example
| > > the distance between the p before and after calling distance(p, n)
| > > is supposed to be n. So I would suggest conversion to the
| > > difference_type of the iterator as a momentary resolution.
| >
| > Excellent idea.
|
| FYI, I suggested tests for > 0 and < 0 as MSVC 7.1 does it that way.
|
| If you convert Distance to difference_type the question is what happens
| if Distance is i.e. 0.2. Do you advance by 0 or 1 position?
does not that follow from the conversion rule?
-- Gaby
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26020
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug libstdc++/26020] std::advance() isn't stable for floating point numbers
2006-01-29 23:06 [Bug libstdc++/26020] New: std::advance() isn't stable for floating point numbers Woebbeking at web dot de
` (10 preceding siblings ...)
2006-01-30 7:54 ` gdr at integrable-solutions dot net
@ 2006-01-30 12:03 ` Woebbeking at web dot de
2006-01-30 12:50 ` gdr at integrable-solutions dot net
` (3 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Woebbeking at web dot de @ 2006-01-30 12:03 UTC (permalink / raw)
To: gcc-bugs
------- Comment #12 from Woebbeking at web dot de 2006-01-30 12:03 -------
Subject: Re: std::advance() isn't stable for floating point numbers
On Monday 30 January 2006 08:54, gdr at integrable-solutions dot net
wrote:
> ------- Comment #11 from gdr at integrable-solutions dot net
> | FYI, I suggested tests for > 0 and < 0 as MSVC 7.1 does it that
> | way.
> |
> | If you convert Distance to difference_type the question is what
> | happens if Distance is i.e. 0.2. Do you advance by 0 or 1 position?
>
> does not that follow from the conversion rule?
Of course. I meant what should it do. Do you want it to advance by 0 or
1 position? Do we just use a simple cast or do we need to do some
rounding? AFAIK MSVC advance by 1 in this case.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26020
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug libstdc++/26020] std::advance() isn't stable for floating point numbers
2006-01-29 23:06 [Bug libstdc++/26020] New: std::advance() isn't stable for floating point numbers Woebbeking at web dot de
` (11 preceding siblings ...)
2006-01-30 12:03 ` Woebbeking at web dot de
@ 2006-01-30 12:50 ` gdr at integrable-solutions dot net
2006-10-17 13:01 ` pcarlini at suse dot de
` (2 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: gdr at integrable-solutions dot net @ 2006-01-30 12:50 UTC (permalink / raw)
To: gcc-bugs
------- Comment #13 from gdr at integrable-solutions dot net 2006-01-30 12:50 -------
Subject: Re: std::advance() isn't stable for floating point numbers
"Woebbeking at web dot de" <gcc-bugzilla@gcc.gnu.org> writes:
| Subject: Re: std::advance() isn't stable for floating point numbers
|
| On Monday 30 January 2006 08:54, gdr at integrable-solutions dot net
| wrote:
| > ------- Comment #11 from gdr at integrable-solutions dot net
|
| > | FYI, I suggested tests for > 0 and < 0 as MSVC 7.1 does it that
| > | way.
| > |
| > | If you convert Distance to difference_type the question is what
| > | happens if Distance is i.e. 0.2. Do you advance by 0 or 1 position?
| >
| > does not that follow from the conversion rule?
|
| Of course. I meant what should it do. Do you want it to advance by 0 or
| 1 position? Do we just use a simple cast or do we need to do some
| rounding? AFAIK MSVC advance by 1 in this case.
Given that Distance is supposed to behave "like" en integral type in
the first place, I would simply use:
(1) implicit conversion to convert it to difference_type;
(2) advance the number of time computed from (1).
-- Gaby
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26020
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug libstdc++/26020] std::advance() isn't stable for floating point numbers
2006-01-29 23:06 [Bug libstdc++/26020] New: std::advance() isn't stable for floating point numbers Woebbeking at web dot de
` (12 preceding siblings ...)
2006-01-30 12:50 ` gdr at integrable-solutions dot net
@ 2006-10-17 13:01 ` pcarlini at suse dot de
2006-10-17 15:17 ` paolo at gcc dot gnu dot org
2006-10-17 15:18 ` pcarlini at suse dot de
15 siblings, 0 replies; 17+ messages in thread
From: pcarlini at suse dot de @ 2006-10-17 13:01 UTC (permalink / raw)
To: gcc-bugs
--
pcarlini at suse dot de changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |pcarlini at suse dot de
|dot org |
Status|NEW |ASSIGNED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26020
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug libstdc++/26020] std::advance() isn't stable for floating point numbers
2006-01-29 23:06 [Bug libstdc++/26020] New: std::advance() isn't stable for floating point numbers Woebbeking at web dot de
` (13 preceding siblings ...)
2006-10-17 13:01 ` pcarlini at suse dot de
@ 2006-10-17 15:17 ` paolo at gcc dot gnu dot org
2006-10-17 15:18 ` pcarlini at suse dot de
15 siblings, 0 replies; 17+ messages in thread
From: paolo at gcc dot gnu dot org @ 2006-10-17 15:17 UTC (permalink / raw)
To: gcc-bugs
------- Comment #14 from paolo at gcc dot gnu dot org 2006-10-17 15:17 -------
Subject: Bug 26020
Author: paolo
Date: Tue Oct 17 15:17:32 2006
New Revision: 117827
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=117827
Log:
2006-10-17 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/26020
* include/bits/stl_iterator_base_funcs.h (advance): Convert
distance parameter to iterator_traits<>::difference_type.
* testsuite/24_iterators/26020.cc: New.
Added:
trunk/libstdc++-v3/testsuite/24_iterators/26020.cc
Modified:
trunk/libstdc++-v3/ChangeLog
trunk/libstdc++-v3/include/bits/stl_iterator_base_funcs.h
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26020
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug libstdc++/26020] std::advance() isn't stable for floating point numbers
2006-01-29 23:06 [Bug libstdc++/26020] New: std::advance() isn't stable for floating point numbers Woebbeking at web dot de
` (14 preceding siblings ...)
2006-10-17 15:17 ` paolo at gcc dot gnu dot org
@ 2006-10-17 15:18 ` pcarlini at suse dot de
15 siblings, 0 replies; 17+ messages in thread
From: pcarlini at suse dot de @ 2006-10-17 15:18 UTC (permalink / raw)
To: gcc-bugs
------- Comment #15 from pcarlini at suse dot de 2006-10-17 15:18 -------
Fixed for 4.2.0.
--
pcarlini at suse dot de changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
Target Milestone|--- |4.2.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26020
^ permalink raw reply [flat|nested] 17+ messages in thread