Re: -Wconversion versus libstdc++

2007-01-18 Thread Gabriel Dos Reis
On Thu, 18 Jan 2007, Manuel López-Ibáñez wrote: | On 18/01/07, Gabriel Dos Reis <[EMAIL PROTECTED]> wrote: | > On Thu, 18 Jan 2007, Manuel López-Ibáñez wrote: | > | > [...] | > | > | > As the PR you noted, it wasn't part of C++. | > | > | > | | > | You are wrong. | > | > "the PR you noted" is | >

Re: -Wconversion versus libstdc++

2007-01-18 Thread Manuel López-Ibáñez
On 18/01/07, Gabriel Dos Reis <[EMAIL PROTECTED]> wrote: On Thu, 18 Jan 2007, Manuel López-Ibáñez wrote: [...] | > As the PR you noted, it wasn't part of C++. | > | | You are wrong. "the PR you noted" is http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26167#c3 which you described as your favo

Re: -Wconversion versus libstdc++

2007-01-18 Thread Gabriel Dos Reis
On Thu, 18 Jan 2007, Robert Dewar wrote: | Gabriel Dos Reis wrote: | | > The pragma thing will be fixed; however, we will still be left with | > unhelful warning for what has become idiomatic because of the way C++ | > tends to see sequences. | | In Ada, we changed things a while ago to give warni

Re: -Wconversion versus libstdc++

2007-01-18 Thread Gabriel Dos Reis
"Manuel López-Ibáñez" <[EMAIL PROTECTED]> writes: [...] | I just felt that the conversation was going in the direction of "we | should shut the warnings of Wconversion up because people using it | will get warnings for libstdc++". I'm afraid you did not read the conversation carefully. -- Gaby

Re: -Wconversion versus libstdc++

2007-01-18 Thread Robert Dewar
Gabriel Dos Reis wrote: The pragma thing will be fixed; however, we will still be left with unhelful warning for what has become idiomatic because of the way C++ tends to see sequences. In Ada, we changed things a while ago to give warnings ONLY on the extended main unit being compiled, and no

Re: -Wconversion versus libstdc++

2007-01-18 Thread Gabriel Dos Reis
On Thu, 18 Jan 2007, Paolo Carlini wrote: | Manuel -- | | > I read it and still don't get it. We know we should not warn about | > system headers but we do and that is a known bug. So again, why is | > libstdc++ using Wconversion at all? | | I appreciate your help with this issue, and I'm confiden

Re: -Wconversion versus libstdc++

2007-01-18 Thread Gabriel Dos Reis
On Thu, 18 Jan 2007, Manuel López-Ibáñez wrote: [...] | > As the PR you noted, it wasn't part of C++. | > | | You are wrong. "the PR you noted" is http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26167#c3 which you described as your favorite. The PR starts with this gcc reports the signedne

Re: -Wconversion versus libstdc++

2007-01-18 Thread Manuel López-Ibáñez
On 18/01/07, Paolo Carlini <[EMAIL PROTECTED]> wrote: Manuel -- > I read it and still don't get it. We know we should not warn about > system headers but we do and that is a known bug. So again, why is > libstdc++ using Wconversion at all? I appreciate your help with this issue, and I'm confide

Re: -Wconversion versus libstdc++

2007-01-18 Thread Paolo Carlini
Manuel -- I read it and still don't get it. We know we should not warn about system headers but we do and that is a known bug. So again, why is libstdc++ using Wconversion at all? I appreciate your help with this issue, and I'm confident that we'll soon converge to a nice solution. Thanks, re

Re: -Wconversion versus libstdc++

2007-01-18 Thread Manuel López-Ibáñez
On 18/01/07, Gabriel Dos Reis <[EMAIL PROTECTED]> wrote: On Thu, 18 Jan 2007, Manuel López-Ibáñez wrote: | On 18/01/07, Gabriel Dos Reis <[EMAIL PROTECTED]> wrote: | > On Thu, 18 Jan 2007, Manuel López-Ibáñez wrote: | > | > | Does that apply also to: | > | | > | unsigned int y = -10; | > | > Yes

Re: -Wconversion versus libstdc++

2007-01-17 Thread Gabriel Dos Reis
On Wed, 17 Jan 2007, Andrew Pinski wrote: | > | > One use of -Wconversion is to draw attention to | > | >int x = 2.3; // warning: be careful, is this what you want? | > // this is a potential bug as it is value altering. | > | > and in an upcoming revision to C++, it is ver

Re: -Wconversion versus libstdc++

2007-01-17 Thread Andrew Pinski
> > One use of -Wconversion is to draw attention to > >int x = 2.3; // warning: be careful, is this what you want? > // this is a potential bug as it is value altering. > > and in an upcoming revision to C++, it is very likely that implicit > conversion that may lose info

Re: -Wconversion versus libstdc++

2007-01-17 Thread Gabriel Dos Reis
On Thu, 18 Jan 2007, Manuel López-Ibáñez wrote: | On 18/01/07, Gabriel Dos Reis <[EMAIL PROTECTED]> wrote: | > On Thu, 18 Jan 2007, Manuel López-Ibáñez wrote: | > | > | Does that apply also to: | > | | > | unsigned int y = -10; | > | > Yes. | > | | Then, why Wconversion has warned about it at leas

Re: -Wconversion versus libstdc++

2007-01-17 Thread Manuel López-Ibáñez
On 18/01/07, Gabriel Dos Reis <[EMAIL PROTECTED]> wrote: On Thu, 18 Jan 2007, Manuel López-Ibáñez wrote: | Does that apply also to: | | unsigned int y = -10; Yes. Then, why Wconversion has warned about it at least since http://gcc.gnu.org/onlinedocs/gcc-3.0.4/gcc_3.html#SEC11 ? Moreover, mo

Re: -Wconversion versus libstdc++

2007-01-17 Thread Gabriel Dos Reis
On Thu, 18 Jan 2007, Joseph S. Myers wrote: [...] | > Furthermore, elsewhere (in the overflow thread) it has been suggested | > that people should convert to the unsigned variants, do computations there, | > and convert back to the signed variants. We have just promised an | > invariant that we

Re: -Wconversion versus libstdc++

2007-01-17 Thread Joseph S. Myers
On Wed, 17 Jan 2007, Gabriel Dos Reis wrote: > The specific cases I'm concerned about here (and if you have a chance > to build firefox for example, you'll see) is when T and U differ only > in signedness, that is > >T = int, U = unsigned >T = long, U = unsigned long >T = long long, U

Re: -Wconversion versus libstdc++

2007-01-17 Thread Gabriel Dos Reis
On Thu, 18 Jan 2007, Manuel López-Ibáñez wrote: | On 18/01/07, Gabriel Dos Reis <[EMAIL PROTECTED]> wrote: | > On Wed, 17 Jan 2007, Manuel López-Ibáñez wrote: | > | > | On 17/01/07, Paolo Carlini <[EMAIL PROTECTED]> wrote: | > | > ... thanks a lot Gaby both for your practical and theoretical | > |

Re: -Wconversion versus libstdc++

2007-01-17 Thread Manuel López-Ibáñez
On 18/01/07, Gabriel Dos Reis <[EMAIL PROTECTED]> wrote: On Wed, 17 Jan 2007, Manuel López-Ibáñez wrote: | On 17/01/07, Paolo Carlini <[EMAIL PROTECTED]> wrote: | > ... thanks a lot Gaby both for your practical and theoretical | > investigations into this issue, both right to the point! Now, in

Re: -Wconversion versus libstdc++

2007-01-17 Thread Gabriel Dos Reis
On Wed, 17 Jan 2007, Manuel López-Ibáñez wrote: | On 17/01/07, Paolo Carlini <[EMAIL PROTECTED]> wrote: | > ... thanks a lot Gaby both for your practical and theoretical | > investigations into this issue, both right to the point! Now, in my | > opinion, we should simply remove the bits about sign

Re: -Wconversion versus libstdc++

2007-01-17 Thread Manuel López-Ibáñez
On 17/01/07, Richard Guenther <[EMAIL PROTECTED]> wrote: I agree this warning is of questionable use and should be not enabled with -Wall. But... -Wconversion is not enabled by -Wall! It is not even enabled by Wextra! It is only enabled by -Wconversion. Getting confused, Manuel.

Re: -Wconversion versus libstdc++

2007-01-17 Thread Manuel López-Ibáñez
On 17/01/07, Paolo Carlini <[EMAIL PROTECTED]> wrote: ... thanks a lot Gaby both for your practical and theoretical investigations into this issue, both right to the point! Now, in my opinion, we should simply remove the bits about signed -> unsigned from -Wconversion. I am not sure I am follo

Re: -Wconversion versus libstdc++

2007-01-17 Thread Joe Buck
I wrote: > | Careful. As you suggest, let's restrict ourselves to two's complement > | platforms. I would want the compiler to warn if the identity holds for an > | ILP32 machine but not an LP64 machine, even if I'm running on an ILP32. > | But if the two types are going to be the same size ever

Re: -Wconversion versus libstdc++

2007-01-17 Thread Gabriel Dos Reis
On Wed, 17 Jan 2007, Joe Buck wrote: | On Wed, Jan 17, 2007 at 04:36:04PM -0600, Gabriel Dos Reis wrote: | > I just built firefox (CVS) with GCC mainline. The compiler spitted | > avalanches of non-sensical warning about conversions signed -> | > unsigned may alter values, when in fact the compil

Re: -Wconversion versus libstdc++

2007-01-17 Thread Paolo Carlini
Joe Buck wrote: Careful. As you suggest, let's restrict ourselves to two's complement platforms. I would want the compiler to warn if the identity holds for an ILP32 machine but not an LP64 machine, even if I'm running on an ILP32. But if the two types are going to be the same size everywhere

Re: -Wconversion versus libstdc++

2007-01-17 Thread Gabriel Dos Reis
On Wed, 17 Jan 2007, Richard Guenther wrote: | On 17 Jan 2007 16:36:04 -0600, Gabriel Dos Reis <[EMAIL PROTECTED]> wrote: | > Paolo Carlini <[EMAIL PROTECTED]> writes: | > | > | Joe Buck wrote: | > | | > | >In the case of the containers, we are asserting/relying on the fact that | > | >the pointer

Re: -Wconversion versus libstdc++

2007-01-17 Thread Joe Buck
On Wed, Jan 17, 2007 at 04:36:04PM -0600, Gabriel Dos Reis wrote: > I just built firefox (CVS) with GCC mainline. The compiler spitted > avalanches of non-sensical warning about conversions signed -> > unsigned may alter values, when in fact the compiler knows that > such things cannot happen. >

Re: -Wconversion versus libstdc++

2007-01-17 Thread Paolo Carlini
... thanks a lot Gaby both for your practical and theoretical investigations into this issue, both right to the point! Now, in my opinion, we should simply remove the bits about signed -> unsigned from -Wconversion. Paolo.

Re: -Wconversion versus libstdc++

2007-01-17 Thread Richard Guenther
On 17 Jan 2007 16:36:04 -0600, Gabriel Dos Reis <[EMAIL PROTECTED]> wrote: Paolo Carlini <[EMAIL PROTECTED]> writes: | Joe Buck wrote: | | >In the case of the containers, we are asserting/relying on the fact that | >the pointer difference is zero or positive. But this has become a | >widespread

Re: -Wconversion versus libstdc++

2007-01-17 Thread Gabriel Dos Reis
Paolo Carlini <[EMAIL PROTECTED]> writes: | Joe Buck wrote: | | >In the case of the containers, we are asserting/relying on the fact that | >the pointer difference is zero or positive. But this has become a | >widespread idiom: people write their own code in the STL style. If STL | >code now ha

Re: -Wconversion versus libstdc++

2007-01-15 Thread Paolo Carlini
Gabriel Dos Reis wrote: The system_header pragma + template issue is separate, and I thought it was resolved a long time ago -- apparently no. It is related to our failure to copy a bit from a template _DECL. Thanks, can you look a bit more into it? Paolo.

Re: -Wconversion versus libstdc++

2007-01-15 Thread Gabriel Dos Reis
On Mon, 15 Jan 2007, Paolo Carlini wrote: | About the library itself, I'm also concerned by the weakness of our | pragma system_header vs templates, which makes the whole warning game | always very dangerous... The system_header pragma + template issue is separate, and I thought it was resolved a

Re: -Wconversion versus libstdc++

2007-01-15 Thread Paolo Carlini
Joe Buck wrote: In the case of the containers, we are asserting/relying on the fact that the pointer difference is zero or positive. But this has become a widespread idiom: people write their own code in the STL style. If STL code now has to be fixed to silence warnings, so will a lot of user

Re: -Wconversion versus libstdc++

2007-01-15 Thread Joe Buck
On Mon, Jan 15, 2007 at 10:24:40AM -0600, Gabriel Dos Reis wrote: > Paolo Carlini <[EMAIL PROTECTED]> writes: > > [...] > > | Let's wait a bit more for other opinions, say one day or two, then I > | will start the actual work. As far as I can see, other compilers do > | not warn in such cases, an

Re: -Wconversion versus libstdc++

2007-01-15 Thread Gabriel Dos Reis
Paolo Carlini <[EMAIL PROTECTED]> writes: [...] | In summary, for v3, one possibility could be combining the two | quantities, consistently for all the containers, thus, essentially, | compute container::max_size as min(allocator::max_size, | numeric_limits::max) (all the computations modulo | si

Re: -Wconversion versus libstdc++

2007-01-15 Thread Paolo Carlini
Paolo Carlini wrote: So, yes, you can add the casts as a temporary work-around. By the way, probably now I see why you consider the two issues related and (some) casts temporary: in the case of vector, for example (not in the case of deque) we are currently using in many places size_type, w

Re: -Wconversion versus libstdc++

2007-01-15 Thread Paolo Carlini
Gabriel Dos Reis wrote: | However, in order not to mix different issues, I think we should try | first to resolve the much more limited issue at hand, which, I note, | has to do with *deallocation*, not with *allocation*. By the time we deallocate, any possible damage has already be done :-) So

Re: -Wconversion versus libstdc++

2007-01-15 Thread Gabriel Dos Reis
Paolo Carlini <[EMAIL PROTECTED]> writes: [...] | >My concern is for vectors whose size() exceeds | > numeric_limits::max() -- even if we would like to | > avoid the general discussion. My understanding -- and I would like | > to hear of others' -- is that the | >semantics description in the tab

Re: -Wconversion versus libstdc++

2007-01-15 Thread Paolo Carlini
Gabriel Dos Reis wrote: | Coming to the specific issue, and *assuming* we agree about the | usefulness of warning for signed -> unsigned, maybe we are "lucky", in | this sense: Table 65 says *explicitely* that size_type can represent | any non-negative value of difference_type. Thus, as I see th

Re: -Wconversion versus libstdc++

2007-01-15 Thread Gabriel Dos Reis
"Manuel López-Ibáñez" <[EMAIL PROTECTED]> writes: [...] | I vote against adding Wconversion to Wall before 4.3 is branched. We are not in voting mode yet :-) -- Gaby

Re: -Wconversion versus libstdc++

2007-01-15 Thread Manuel López-Ibáñez
On 15/01/07, Martin Sebor <[EMAIL PROTECTED]> wrote: Paolo Carlini wrote: > > Anyway, note that our -Wconversion is not part of -Wall, not even > -Wextra: are you maintaining that probably the bits having to do with > float <-> integer should also be part of -Wall or at least -Wextra? We use bot

Re: -Wconversion versus libstdc++

2007-01-15 Thread Gabriel Dos Reis
Paolo Carlini <[EMAIL PROTECTED]> writes: | Hi Gaby, | | >There is something that we knoq about the code, that the compiler | >does not have: we expect a sequence denoted by its first and last | >element, so that the difference is always positive. However, the | >difference of pointers is define

Re: -Wconversion versus libstdc++

2007-01-15 Thread Martin Sebor
Paolo Carlini wrote: Martin Sebor wrote: FYI: HP aCC warns for some but not all of these types of lossy initializations. For example, a double to int conversion emits a warning but ptrdiff_t to size_t or other signed to unsigned conversions do not, probably because they're so common. I find thi

Re: -Wconversion versus libstdc++

2007-01-15 Thread Paolo Carlini
Hi Gaby, There is something that we knoq about the code, that the compiler does not have: we expect a sequence denoted by its first and last element, so that the difference is always positive. However, the difference of pointers is defined in the language as an ptrdiff_t (a signed type). No wo

Re: -Wconversion versus libstdc++

2007-01-15 Thread Gabriel Dos Reis
Paolo Carlini <[EMAIL PROTECTED]> writes: [...] | Let's wait a bit more for other opinions, say one day or two, then I | will start the actual work. As far as I can see, other compilers do | not warn in such cases, and adding casts (*) isn't the cleanest | practice in the world, thus my caution..

Re: -Wconversion versus libstdc++

2007-01-15 Thread Gabriel Dos Reis
Paolo Carlini <[EMAIL PROTECTED]> writes: | Hi Manuel, | | >> in a nutshell, what is happening is that a difference of two pointers is | >> assigned to an unsigned variable. First blush, the warning seems to me a | >> bit overzealous, but if we concur that this is what we *really* want for | >> 4

Re: -Wconversion versus libstdc++

2007-01-15 Thread Gabriel Dos Reis
Paolo Carlini <[EMAIL PROTECTED]> writes: | Hi Gerald, | | >I noticed that -Wconversion now issues warnings in libstdc++. | > | in a nutshell, what is happening is that a difference of two pointers | is assigned to an unsigned variable. First blush, the warning seems to | me a bit overzealous, bu

Re: -Wconversion versus libstdc++

2007-01-15 Thread Paolo Carlini
Martin Sebor wrote: FYI: HP aCC warns for some but not all of these types of lossy initializations. For example, a double to int conversion emits a warning but ptrdiff_t to size_t or other signed to unsigned conversions do not, probably because they're so common. I find this behavior useful. T

Re: -Wconversion versus libstdc++

2007-01-14 Thread Martin Sebor
Paolo Carlini wrote: [...] Let's wait a bit more for other opinions, say one day or two, then I will start the actual work. As far as I can see, other compilers do not warn in such cases, and adding casts (*) isn't the cleanest practice in the world, thus my caution... FYI: HP aCC warns for s

Re: -Wconversion versus libstdc++

2007-01-14 Thread Paolo Carlini
Gerald Pfeifer wrote: On Mon, 15 Jan 2007, Paolo Carlini wrote: All in all, I think we can definitely add casts to the library, would be only a few tens of lines worth of patch, I think. Whether the warning is useful to the entire GCC community, I cannot say... But I hope we can resolve the

Re: -Wconversion versus libstdc++

2007-01-14 Thread Gerald Pfeifer
On Mon, 15 Jan 2007, Paolo Carlini wrote: > All in all, I think we can definitely add casts to the library, would be only > a few tens of lines worth of patch, I think. Whether the warning is useful to > the entire GCC community, I cannot say... But I hope we can resolve the issue > rather quickly,

Re: -Wconversion versus libstdc++

2007-01-14 Thread Paolo Carlini
Manuel López-Ibáñez wrote: The casts should avoid the warnings and using Wno-conversion also. To be clear: we *cannot* ask the users to avoid Wconversion with the library or whatever other warning only because our pragma system header is weak with templates, or the compiler overzealous. I ag

Re: -Wconversion versus libstdc++

2007-01-14 Thread Manuel López-Ibáñez
On 14/01/07, Paolo Carlini <[EMAIL PROTECTED]> wrote: Hi Manuel, Well, just have a look to Gerald' examples: it's old HP / SGI STL code, we are assigning / initializing a size_t from a pointer difference, or arithmetic, more generally. There are quite a few instances of the issue, beyond that p

Re: -Wconversion versus libstdc++

2007-01-14 Thread Paolo Carlini
Hi Manuel, in a nutshell, what is happening is that a difference of two pointers is assigned to an unsigned variable. First blush, the warning seems to me a bit overzealous, but if we concur that this is what we *really* want for 4.3, we can change the affected (very old, indeed) lines of code,

Re: -Wconversion versus libstdc++

2007-01-14 Thread Manuel López-Ibáñez
On 14/01/07, Paolo Carlini <[EMAIL PROTECTED]> wrote: Hi Gerald, >I noticed that -Wconversion now issues warnings in libstdc++. > > in a nutshell, what is happening is that a difference of two pointers is assigned to an unsigned variable. First blush, the warning seems to me a bit overzealous, b

Re: -Wconversion versus libstdc++

2007-01-14 Thread Manuel López-Ibáñez
On 14/01/07, Gerald Pfeifer <[EMAIL PROTECTED]> wrote: I noticed that -Wconversion now issues warnings in libstdc++. The purpose of Wconversion has changed. You can know more about it here: http://gcc.gnu.org/wiki/NewWconversion For now I have opened two bug reports, and I plan to continue t

Re: -Wconversion versus libstdc++

2007-01-14 Thread Paolo Carlini
Hi Gerald, I noticed that -Wconversion now issues warnings in libstdc++. in a nutshell, what is happening is that a difference of two pointers is assigned to an unsigned variable. First blush, the warning seems to me a bit overzealous, but if we concur that this is what we *really* want for

-Wconversion versus libstdc++

2007-01-14 Thread Gerald Pfeifer
I noticed that -Wconversion now issues warnings in libstdc++. For now I have opened two bug reports, and I plan to continue testing and file further bug reports once these have been fixed but I wonder if anyone plans to do a more systemastic set of checks? libstdc++/30463 [regression] -Wconve