Re: basic VRP min/max range overflow question

2005-07-19 Thread Michael Veksler
Sebastian Pop <[EMAIL PROTECTED]> wrote on 19/07/2005 12:58:23: | Michael Veksler wrote: | > This is problematic: | > 1. I am not sure it will turn the warning off. | | So you don't want a warning that cannot be turned off simply by | modifying the code. Most of gcc warnings are like that: you

Re: basic VRP min/max range overflow question

2005-07-19 Thread Sebastian Pop
Michael Veksler wrote: > This is problematic: > 1. I am not sure it will turn the warning off. So you don't want a warning that cannot be turned off simply by modifying the code. Then, I withdraw the patch that I have proposed to implement the warning.

Re: basic VRP min/max range overflow question

2005-07-19 Thread Michael Veksler
Sebastian Pop wrote on 19/07/2005 09:49:11: > Robert Dewar wrote: > > > > and that is called a false positive if in fact the loop does > > not overrun. this sounds very dubious to me I concur. > > The problem is that the compiler has no other information about the > number of iterations in t

Re: basic VRP min/max range overflow question

2005-07-18 Thread Sebastian Pop
Robert Dewar wrote: > > and that is called a false positive if in fact the loop does > not overrun. this sounds very dubious to me The problem is that the compiler has no other information about the number of iterations in the loop, otherwise it wouldn't spend cycles on computing such estimations

Re: basic VRP min/max range overflow question

2005-07-18 Thread Robert Dewar
Sebastian Pop wrote: I don't really see what a false positive could be in this case. In the patch that I have proposed, the warning is triggered every time the flag -Wloop-bound-estimated is used and the loop optimizer triggers the estimation of loop bounds for a parametric loop, as in the foll

Re: basic VRP min/max range overflow question

2005-07-18 Thread Sebastian Pop
Robert Dewar wrote: > > As with all warnings, you have to run this over a large test suite > of real applications to find out whether there are too many false > positives. I don't really see what a false positive could be in this case. In the patch that I have proposed, the warning is triggered

Re: basic VRP min/max range overflow question

2005-07-13 Thread DJ Delorie
> > I think we would like them better if you could choose to silence them, > > especially when people use -Werror. > > How can I do this? Create a -W* command line option for it. Pass the corresponding OPT_* to warning(). Theen the -W option controls that warning. > I have just mimicked one

Re: basic VRP min/max range overflow question

2005-07-13 Thread Sebastian Pop
DJ Delorie wrote: > > > Then, you will like the following kind of patches: > > > > + warning (0, "%H undefined behavior if loop runs for more than %qE > > iterations", > > + find_loop_location (loop), estimation); > > I think we would like them better if you could choose to silenc

Re: basic VRP min/max range overflow question

2005-06-21 Thread Robert Dewar
Sebastian Pop wrote: This is the best the compiler can do: it has warned the user of a possible undefined behavior in the code, and that it will use this assumption for transforming the code. As with all warnings, you have to run this over a large test suite of real applications to find out wh

Re: basic VRP min/max range overflow question

2005-06-20 Thread Mike Stump
On Jun 18, 2005, at 11:50 AM, Paul Schlie wrote: [ curiously can't find any actual reference stating that integer overflow is specifically results in undefined behavior, although it's obviously ill defined? Every operation that isn't defined is undefined. Only the operations that are de

Re: basic VRP min/max range overflow question

2005-06-20 Thread Mike Stump
General note, please, this list is for developers of gcc to develop gcc. Using it as a way to teach yourself how to read the C standard, isn't ok, please stop. On Saturday, June 18, 2005, at 07:15 AM, Paul Schlie wrote: Maybe I didn't phrase my statement well; I think you did, you are j

Re: basic VRP min/max range overflow question

2005-06-20 Thread Kai Henningsen
[EMAIL PROTECTED] (Robert Dewar) wrote on 19.06.05 in <[EMAIL PROTECTED]>: > Kai Henningsen wrote: > > > But at least, in that case, the compiler could easily issue the > > (presumably not required by the standard) warning that the else branch is > > "unreachable code". > > Yes, absolutely, a com

Re: basic VRP min/max range overflow question

2005-06-20 Thread DJ Delorie
> Then, you will like the following kind of patches: > > + warning (0, "%H undefined behavior if loop runs for more than %qE > iterations", > +find_loop_location (loop), estimation); I think we would like them better if you could choose to silence them, especially when people u

Re: basic VRP min/max range overflow question

2005-06-20 Thread Paul Schlie
> From: Michael Veksler <[EMAIL PROTECTED]> >> Paul Schlie <[EMAIL PROTECTED]> wrote on 20/06/2005 16:09:16: >>> From: Michael Veksler <[EMAIL PROTECTED]>> >>> As for overflow, you can say that you want instead of "undefined" >>> to treat is "unspecified". Where each architecture / opsys / compiler

Re: basic VRP min/max range overflow question

2005-06-20 Thread Michael Veksler
Paul Schlie <[EMAIL PROTECTED]> wrote on 20/06/2005 16:09:16: > > From: Michael Veksler <[EMAIL PROTECTED]>> > > As for overflow, you can say that you want instead of "undefined" > > to treat is "unspecified". Where each architecture / opsys / compiler > > must consistently define what happens

Re: basic VRP min/max range overflow question

2005-06-20 Thread Sebastian Pop
Robert Dewar wrote: > Yes, absolutely, a compiler should generate warnings as much as possible when > it is making these kind of assujmptions. Then, you will like the following kind of patches: Index: tree-data-ref.c === RCS file: /c

Re: basic VRP min/max range overflow question

2005-06-20 Thread Robert Dewar
Paul Schlie wrote: - yes, effectively I don't perceive any necessity for undefined, vs unspecified; as I don't perceive any necessity to give the compiler the freedom to treat generate an arbitrary program which may contain a potentially ambiguous specific and isolatable behavior. OK, then you

Re: basic VRP min/max range overflow question

2005-06-20 Thread Robert Dewar
Paul Schlie wrote: There don't need to be examples. The as-if rule always applies, if you cannot write a legitimate C program that shows the difference between two possible implementations, then both are correct. ??? as-if means they're logically equivalent (i.e. there is no logical differenc

Re: basic VRP min/max range overflow question

2005-06-20 Thread Paul Schlie
> From: Michael Veksler <[EMAIL PROTECTED]>> >> Paul Schlie wrote on 20/06/2005 14:13:33: >>> From: Robert Dewar <[EMAIL PROTECTED]> > ... >>> Note that in the cases where something is statically optimized away >>> (these are the easy cases), it is nice if the compiler warns that this >>> is happen

Re: basic VRP min/max range overflow question

2005-06-20 Thread Paul Schlie
> From: Robert Dewar <[EMAIL PROTECTED]> >> Paul Schlie wrote: > >> - You may be correct, although it's not obviously the case? (As requiring >> all undefined behavior be encapsulated between sequence points already >> seems implied to me, as I don't see any explicit counter examples >> requ

Re: basic VRP min/max range overflow question

2005-06-20 Thread Robert Dewar
Michael Veksler wrote: As for overflow, you can say that you want instead of "undefined" to treat is "unspecified". In Ada 95 we introduced a new category of behavior, called a bounded error. We tried to recategorize as many erroneous (= C undefined) cases as possible to bounded error. A bou

Re: basic VRP min/max range overflow question

2005-06-20 Thread Michael Veksler
Paul Schlie wrote on 20/06/2005 14:13:33: > > From: Robert Dewar <[EMAIL PROTECTED]> ... > > Note that in the cases where something is statically optimized away (these > > are the easy cases), it is nice if the compiler warns that this is happening > > (that would certainly be the case in Ada

Re: basic VRP min/max range overflow question

2005-06-20 Thread Robert Dewar
Michael Veksler wrote: Getting a consistent definition of "bounded side-effects" is a nontrivial task. Simply hacking and patching the definition does not work. Trust me, I've been there done that, got burnt and are still paying for my sins. Indeed! I think anyone who has been involved in the

Re: basic VRP min/max range overflow question

2005-06-20 Thread Robert Dewar
Paul Schlie wrote: - You may be correct, although it's not obviously the case? (As requiring all undefined behavior be encapsulated between sequence points already seems implied to me, as I don't see any explicit counter examples requiring otherwise. There don't need to be examples. The

Re: basic VRP min/max range overflow question

2005-06-20 Thread Michael Veksler
Paul Schlie <[EMAIL PROTECTED]> wrote on 20/06/2005 14:03:53: > > From: Michael Veksler <[EMAIL PROTECTED]> ... > > Almost any optimization over line 8 will change the > > behavior of line 4. I believe that you did not intend to > > cover this case in your requirement. Maybe you would > > like

Re: basic VRP min/max range overflow question

2005-06-20 Thread Paul Schlie
> From: Robert Dewar <[EMAIL PROTECTED]> > Paul Schlie wrote: > >> I too believe I understand your position, however don't believe it's the >> compiler's job to make life for the programmer harder than it need be when >> a program may contain an undefined behavior; but agree it would likely >> alw

Re: basic VRP min/max range overflow question

2005-06-20 Thread Paul Schlie
> From: Robert Dewar <[EMAIL PROTECTED]> > Paul Schlie wrote: > >> As in my mind, the semantics of foo() dictate that it print the value of >> the storage location which was allocated to the variable "a", where unless >> "a" is initialized with an explicit value, may be arbitrary. So I've got no >

Re: basic VRP min/max range overflow question

2005-06-20 Thread Robert Dewar
Paul Schlie wrote: I too believe I understand your position, however don't believe it's the compiler's job to make life for the programmer harder than it need be when a program may contain an undefined behavior; but agree it would likely always be helpful to for it to point them out when identif

Re: basic VRP min/max range overflow question

2005-06-20 Thread Robert Dewar
Paul Schlie wrote: As in my mind, the semantics of foo() dictate that it print the value of the storage location which was allocated to the variable "a", where unless "a" is initialized with an explicit value, may be arbitrary. So I've got no problem with arbitrary results or behavior, I just si

Re: basic VRP min/max range overflow question

2005-06-20 Thread Paul Schlie
> From: Robert Dewar <[EMAIL PROTECTED]> > Robert Dewar wrote: > >> That may be your position, but it is not the position of the standard, and >> indeed it is not a well-formed position. Why, because the whole point is >> that >> when the behavior is undefined, then the change DOES yield a logical

Re: basic VRP min/max range overflow question

2005-06-20 Thread Paul Schlie
> From: Robert Dewar <[EMAIL PROTECTED]> > Paul Schlie wrote: > >> My position is simply that an optimization should never remove a specified >> operation unless it is known to yield logically equivalent behavior, as >> producing a program which does not behave as specified is not a good idea > >

Re: basic VRP min/max range overflow question

2005-06-20 Thread Paul Schlie
> From: Michael Veksler <[EMAIL PROTECTED]> > Paul Schlie wrote on 20/06/2005 08:55:20: >> y = z ? z + x;// y == [INT_MIN+1, INT_MAX+2] > Invalid syntax, what did you mean? Sorry, meant: y = z + x; // y == [INT_MIN, INT_MAX] + [1, 2] == [INT_MIN+1, INT_MAX+2] >> I guess I simply believe t

Re: basic VRP min/max range overflow question

2005-06-20 Thread Robert Dewar
Robert Dewar wrote: That may be your position, but it is not the position of the standard, and indeed it is not a well-formed position. Why, because the whole point is that when the behavior is undefined, then the change DOES yield a logically equivalent behavior, because undefined means undef

Re: basic VRP min/max range overflow question

2005-06-20 Thread Robert Dewar
Paul Schlie wrote: My position is simply that an optimization should never remove a specified operation unless it is known to yield logically equivalent behavior, as producing a program which does not behave as specified is not a good idea That may be your position, but it is not the position

Re: basic VRP min/max range overflow question

2005-06-20 Thread Michael Veksler
Paul Schlie wrote on 20/06/2005 08:55:20: > y = z ? z + x;// y == [INT_MIN+1, INT_MAX+2] Invalid syntax, what did you mean? > I guess I simply believe that optimizations should never alter the logical > behavior of a specified program relative to it's un-optimized form unless > explic

Re: basic VRP min/max range overflow question

2005-06-19 Thread Paul Schlie
> From: Robert Dewar <[EMAIL PROTECTED]> >> Paul Schlie wrote: >> The root of the concern being expressed is with respect to the compilers use >> of statically identified undefined behaviors as opportunities to invoke >> alternative semantics which are easily identified as being inconsistent with >

Re: basic VRP min/max range overflow question

2005-06-19 Thread Robert Dewar
Paul Schlie wrote: The root of the concern being expressed is with respect to the compilers use of statically identified undefined behaviors as opportunities to invoke alternative semantics which are easily identified as being inconsistent with the target's native semantics, thus altering the lo

Re: basic VRP min/max range overflow question

2005-06-19 Thread Paul Schlie
> From: Robert Dewar <[EMAIL PROTECTED]> >> Paul Schlie wrote: >>> From: "Joseph S. Myers" <[EMAIL PROTECTED]> >>> "no requirements" means that *any* translation conforms in the case of >>> undefined behavior. Only those executions not involving undefined >>> behavior have any requirements. >> >>

Re: basic VRP min/max range overflow question

2005-06-19 Thread Robert Dewar
Kai Henningsen wrote: But at least, in that case, the compiler could easily issue the (presumably not required by the standard) warning that the else branch is "unreachable code". Yes, absolutely, a compiler should generate warnings as much as possible when it is making these kind of assujm

Re: basic VRP min/max range overflow question

2005-06-19 Thread Kai Henningsen
[EMAIL PROTECTED] (Robert Dewar) wrote on 18.06.05 in <[EMAIL PROTECTED]>: > Here is an interesting example I have used sometimes to indicate just > how this kind of information can propagate in a manner that would result > in unexpected chaos. (Ada but obvious analogies in other languages) > > >

Re: basic VRP min/max range overflow question

2005-06-19 Thread Kai Henningsen
[EMAIL PROTECTED] (Florian Weimer) wrote on 18.06.05 in <[EMAIL PROTECTED]>: > * Paul Schlie: > > > So in effect the standard committee have chosen to allow any program which > > invokes any undefined behavior to behave arbitrarily without diagnosis? > > > > This is a good thing? > > It's the way

Re: basic VRP min/max range overflow question

2005-06-18 Thread Tristan Wibberley
Paul Schlie wrote: [Justification snipped] > Therefore regardless of the result of an "undefined" result/operation at > it's enclosing sequence point, the remaining program must continue to abide > by the specified semantics of the language. Tell that to Mister my_array[sizeof(my_array) / sizeof

Re: basic VRP min/max range overflow question

2005-06-18 Thread Robert Dewar
Paul Schlie wrote: From: "Joseph S. Myers" <[EMAIL PROTECTED]> "no requirements" means that *any* translation conforms in the case of undefined behavior. Only those executions not involving undefined behavior have any requirements. What delineates the bounds between undefined and non-undefine

Re: basic VRP min/max range overflow question

2005-06-18 Thread Robert Dewar
Joseph S. Myers wrote: The traditional form of undefined behavior is for demons to fly out of your nose. We just haven't yet got -fnasal-demons working reliably but it would be conforming for it to be on by default. If you are lucky, it will happen anyway without that option. A nice piece

Re: basic VRP min/max range overflow question

2005-06-18 Thread Florian Weimer
* Paul Schlie: > So in effect the standard committee have chosen to allow any program which > invokes any undefined behavior to behave arbitrarily without diagnosis? > > This is a good thing? It's the way things are. There isn't a real market for bounds-checking C compilers, for example, which o

Re: basic VRP min/max range overflow question

2005-06-18 Thread Robert Dewar
Paul Schlie wrote: - an optimization which presumes the execution state of a program does not proceed past a sequence point. but in fact does, may result in erroneous behavior; which would be the case if NULL pointer comparisons were optimized away presuming an earlier pointer dereference would

Re: basic VRP min/max range overflow question

2005-06-18 Thread Joseph S. Myers
On Sat, 18 Jun 2005, Paul Schlie wrote: > So in effect the standard committee have chosen to allow any program which > invokes any undefined behavior to behave arbitrarily without diagnosis? That is the *whole point* of undefined behavior. Unless the program also violates a compile-time syntax

Re: basic VRP min/max range overflow question

2005-06-18 Thread Paul Schlie
> From: "Joseph S. Myers" <[EMAIL PROTECTED]> > "no requirements" means that *any* translation conforms in the case of > undefined behavior. Only those executions not involving undefined > behavior have any requirements. What delineates the bounds between undefined and non-undefined behaviors? (

Re: basic VRP min/max range overflow question

2005-06-18 Thread Paul Schlie
So in effect the standard committee have chosen to allow any program which invokes any undefined behavior to behave arbitrarily without diagnosis? This is a good thing? [ curiously can't find any actual reference stating that integer overflow is specifically results in undefined behavior, altho

Re: basic VRP min/max range overflow question

2005-06-18 Thread Joseph S. Myers
On Sat, 18 Jun 2005, Paul Schlie wrote: >[#1] Behavior, upon use of a nonportable or erroneous >program construct, of erroneous data, or of indeterminately >valued objects, for which this International Standard >imposes no requirements. Permissibl

Re: basic VRP min/max range overflow question

2005-06-18 Thread Joseph S. Myers
On Sat, 18 Jun 2005, Paul Schlie wrote: > > You appear to have confused unspecified behavior (where the possibilities > > are bounded) and undefined behavior (where the possibilities are > > unbounded). On *undefined* behavior (such as signed integer overflow), > > *this International Standard im

Re: basic VRP min/max range overflow question

2005-06-18 Thread Paul Schlie
Sorry, yes the quote below defines unspecified, not undefined behavior. Now more correctly: [#1] Behavior, upon use of a nonportable or erroneous program construct, of erroneous data, or of indeterminately valued objects, for which this International Standard

Re: basic VRP min/max range overflow question

2005-06-18 Thread Paul Schlie
> From: "Joseph S. Myers" <[EMAIL PROTECTED]> > On Sat, 18 Jun 2005, Paul Schlie wrote: > >> Maybe I didn't phrase my statement well; I fully agree with the cited >> paragraph above which specifically says a program containing unspecified >> behavior "shall be a correct program and act in ac

Re: basic VRP min/max range overflow question

2005-06-18 Thread Joseph S. Myers
On Sat, 18 Jun 2005, Paul Schlie wrote: > Maybe I didn't phrase my statement well; I fully agree with the cited > paragraph above which specifically says a program containing unspecified > behavior "shall be a correct program and act in accordance with > 5.1.2.3". Which specifies program ex

Re: basic VRP min/max range overflow question

2005-06-18 Thread Paul Schlie
> Mike Stump wrote: >> Paul Schlie wrote: >> - If the semantics of an operation are "undefined", I'd agree; but if >> control is returned to the program, the program's remaining specified >> semantics must be correspondingly obeyed, including the those which >> may utilize the resulting value

Re: basic VRP min/max range overflow question

2005-06-18 Thread Toon Moene
Dale Johannesen wrote: 2 NOTE Possible undefined behavior ranges from ignoring the situation completely with unpredictable results, to behaving during translation or program execution in a documented manner characteristic of the environment (with or without the issuance of a diagnostic messag

Re: basic VRP min/max range overflow question

2005-06-17 Thread Mike Stump
On Friday, June 17, 2005, at 05:59 PM, Paul Schlie wrote: - If the semantics of an operation are "undefined", I'd agree; but if control is returned to the program, the program's remaining specified semantics must be correspondingly obeyed, including the those which may utilize the resultin

Re: basic VRP min/max range overflow question

2005-06-17 Thread Robert Dewar
Paul Schlie wrote: (As there's nothing in the standard which enables an implementation to subsequently disregard the resulting value of an implementation specific operation from the best I can tell; although would welcome someone pointing out where specifically it's allowed. As unless

Re: basic VRP min/max range overflow question

2005-06-17 Thread Dale Johannesen
On Jun 17, 2005, at 5:59 PM, Paul Schlie wrote: From: Andrew Pinski <[EMAIL PROTECTED]> On Jun 17, 2005, at 8:20 PM, Paul Schlie wrote: ["undefined" only provides liberties within the constrains of what is specifically specified as being undefined, but none beyond that.] That is not tr

Re: basic VRP min/max range overflow question

2005-06-17 Thread Paul Schlie
> From: Andrew Pinski <[EMAIL PROTECTED]> > On Jun 17, 2005, at 8:20 PM, Paul Schlie wrote: > >> ["undefined" only provides liberties within the constrains of what >> is specifically specified as being undefined, but none beyond that.] > > That is not true. Undefined means it can run "rm /"

Re: basic VRP min/max range overflow question

2005-06-17 Thread Andrew Pinski
On Jun 17, 2005, at 8:20 PM, Paul Schlie wrote: ["undefined" only provides liberties within the constrains of what is specifically specified as being undefined, but none beyond that.] That is not true. Undefined means it can run "rm /" if you ever invoke the undefined code. Thanks, Andr

Re: basic VRP min/max range overflow question

2005-06-17 Thread Paul Schlie
> From: Diego Novillo <[EMAIL PROTECTED]> > On Fri, Jun 17, 2005 at 02:28:58PM -0400, Paul Schlie wrote: > >> int x; >> volatile int v; >> >> x = (v ? 0 : INT_MAX) + 1; // [1, INT_MAX] (without -fwrapv) >> >> if (x <= 0) // Which may be erroneously >> printf("%i is <= 0.",

Re: basic VRP min/max range overflow question

2005-06-17 Thread Diego Novillo
On Fri, Jun 17, 2005 at 02:28:58PM -0400, Paul Schlie wrote: > int x; > volatile int v; > > x = (v ? 0 : INT_MAX) + 1; // [1, INT_MAX] (without -fwrapv) > > if (x <= 0) // Which may be erroneously > printf("%i is <= 0.", x); // optimized away, with this. > else > print

Re: basic VRP min/max range overflow question

2005-06-17 Thread Paolo Bonzini
Paul Schlie wrote: They need not wrap around. People that are actually on the C standards committee have told you this multiple times. Yes, and may clearly produce erroneous results if the value ranges are not consistent with the factual behavior of an implementation, i.e.: Are you li

Re: basic VRP min/max range overflow question

2005-06-17 Thread Paul Schlie
> They need not wrap around. People that are actually on the C standards > committee have told you this multiple times. Yes, and may clearly produce erroneous results if the value ranges are not consistent with the factual behavior of an implementation, i.e.: int x; volatile int v; x = (v ?

Re: basic VRP min/max range overflow question

2005-06-17 Thread Diego Novillo
On Fri, Jun 17, 2005 at 12:27:55AM -0400, Paul Schlie wrote: > Upon a potential integer overflow of either it's min or max range, > shouldn't the result be set to [min:type-min-value, max:type-max-value], > without the necessity of any further designations? > If you want this behaviour, use -fwra

Re: basic VRP min/max range overflow question

2005-06-17 Thread Paolo Bonzini
[#1] The signed C integer types int, long, long long and the corresponding unsigned types are compatible with LIA-1. If an implementation adds support for the LIA-1 exceptional values integer_overflow and undefined, then those types are LIA-1 co

Re: basic VRP min/max range overflow question

2005-06-17 Thread Paul Schlie
> Paolo Bonsini wrote: >> Upon a potential integer overflow of either it's min or max range, >> shouldn't the result be set to [min:type-min-value, max:type-max-value], >> without the necessity of any further designations? > > No. > > [10, INT_MAX] + [ 1, 1 ] == [ 11, INT_MAX ] because of the famo

Re: basic VRP min/max range overflow question

2005-06-17 Thread Paolo Bonzini
Paul Schlie wrote: Upon a potential integer overflow of either it's min or max range, shouldn't the result be set to [min:type-min-value, max:type-max-value], without the necessity of any further designations? No. [10, INT_MAX] + [ 1, 1 ] == [ 11, INT_MAX ] because of the famous signed int ov