[Bug libstdc++/22634] partial_sum is too constrained

gdr at integrable-solutions dot net gcc-bugzilla@gcc.gnu.org
Sun Jul 24 03:27:00 GMT 2005


------- Additional Comments From gdr at integrable-solutions dot net  2005-07-24 03:21 -------
Subject: Re:  partial_sum is too constrained

"bangerth at dealii dot org" <gcc-bugzilla@gcc.gnu.org> writes:

| No, the standard says that the result for an iterator 'i' in the output  
| range is  
|   ((...(*first + *(first + 1)) + ...) + *(first + (i - result)))  
| So arithmetic is done with the data type of the input range. 

However, there is a snag.  In the example submitted by the reporter,
"first" is of type "char*".  So any arithmetic happening, starts by
*promoting* char to int before computation is done.
Consequently, it appears legitimate to expect that intermediate result
being used throughout the accumulation, because it is the natural type
of the result.  

|            What    |Removed                     |Added
| ----------------------------------------------------------------------------
|              Status|UNCONFIRMED                 |RESOLVED
|          Resolution|                            |INVALID

I don't think it is invalid PR.

We may, however,  eithed do The Right Thing; or submit a DR; or do both.

-- Gaby


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22634



More information about the Gcc-bugs mailing list