public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Michael Veksler <VEKSLER@il.ibm.com>
To: Sebastian Pop <sebastian.pop@cri.ensmp.fr>
Cc: Robert Dewar <dewar@adacore.com>,
	gcc@gcc.gnu.org, Kai Henningsen <kaih@khms.westfalen.de>
Subject: Re: basic VRP min/max range overflow question
Date: Tue, 19 Jul 2005 07:07:00 -0000	[thread overview]
Message-ID: <OF42B07BFE.4BCEC179-ON43257043.00260CD6-43257043.00271359@il.ibm.com> (raw)
In-Reply-To: <20050719064910.GA4849@napoca.cri.ensmp.fr>





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 the loop, otherwise it wouldn't spend cycles
> on computing such estimations.  Because the compiler will use the
> estimation for transforming the code, it should warn the user.

But isn't it only an estimation? In other words, does it affect anything
but performance (in case of a wrong estimation)?

>
> If I understand correctly, you would like a warning that says: "your
> code is wrong: you access the array outside the allocated size".
> Well, this is feasible, but then, the warning will be effective only
> on loops that have statically determinable number of iterations.
>
> In my opinion both these warnings are useful.
>
I am not sure about it. If you have false positives that you have
no reasonable way to turn off (other than -Wno-xxxxx), then
the warning is useless. The only alternative for -Wno-xxxxx
in your example would be:

void foo (int N)
{
  int i;
  int A[123];

  if (N > 123) // Turn the warning off.
     abort();
  for (i = 0; i < N; i++)
    A[i] = ...
}

This is problematic:
1. I am not sure it will turn the warning off.
2. Even if it does, this defeats the whole idea of the original
    optimization (gcc could have put the abort - it is allowed
    to do so because N>123 triggers undefined behavior).
3. If the line with A[i]=....  contains a function call then it is
   possible that the function calls exit, abort, longjmp or throw.
   In that case, N>123 is perfectly legal (and my if..abort
   is not viable - so again there is no way to shut the warning
   off).
   I guess that VRP is not allowed to propagate N <= 123 in
   this case.


    Michael

  reply	other threads:[~2005-07-19  7:07 UTC|newest]

Thread overview: 70+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-18 14:15 Paul Schlie
2005-06-18 16:19 ` Joseph S. Myers
2005-06-18 17:44   ` Paul Schlie
2005-06-18 18:05     ` Paul Schlie
2005-06-18 18:21       ` Joseph S. Myers
2005-06-18 18:50         ` Paul Schlie
2005-06-18 19:57           ` Joseph S. Myers
2005-06-18 21:01           ` Florian Weimer
2005-06-19 10:18             ` Kai Henningsen
2005-06-20 22:20           ` Mike Stump
2005-06-18 19:16         ` Paul Schlie
2005-06-18 21:26           ` Robert Dewar
2005-06-19 18:23             ` Paul Schlie
2005-06-20  2:44               ` Robert Dewar
2005-06-20  5:55                 ` Paul Schlie
2005-06-20 10:14                   ` Michael Veksler
2005-06-20 11:04                     ` Paul Schlie
2005-06-20 11:32                       ` Robert Dewar
2005-06-20 12:08                         ` Paul Schlie
2005-06-20 12:39                           ` Robert Dewar
2005-06-20 13:01                             ` Paul Schlie
2005-06-20 13:14                               ` Robert Dewar
2005-06-20 12:23                       ` Michael Veksler
2005-06-20 12:46                         ` Robert Dewar
2005-06-20 10:43                   ` Robert Dewar
2005-06-20 10:54                     ` Robert Dewar
2005-06-20 11:26                       ` Paul Schlie
2005-06-20 11:34                         ` Robert Dewar
2005-06-20 12:09                           ` Paul Schlie
2005-06-20 11:14                     ` Paul Schlie
2005-06-20 12:53                       ` Michael Veksler
2005-06-20 12:59                         ` Robert Dewar
2005-06-20 13:09                         ` Paul Schlie
2005-06-20 13:17                           ` Robert Dewar
2005-06-20 14:54                           ` Michael Veksler
2005-06-20 18:01                             ` Paul Schlie
2005-06-18 18:08     ` Joseph S. Myers
2005-06-18 21:08   ` Robert Dewar
2005-06-19 10:18     ` Kai Henningsen
2005-06-19 10:49       ` Robert Dewar
2005-06-20 13:22         ` Sebastian Pop
2005-06-20 18:10           ` DJ Delorie
2005-07-13  7:57             ` Sebastian Pop
2005-07-13 15:18               ` DJ Delorie
2005-06-21 15:21           ` Robert Dewar
2005-07-18 16:34             ` Sebastian Pop
2005-07-18 16:44               ` Robert Dewar
2005-07-19  6:44                 ` Sebastian Pop
2005-07-19  7:07                   ` Michael Veksler [this message]
2005-07-19  9:55                     ` Sebastian Pop
2005-07-19 10:22                       ` Michael Veksler
2005-06-20 19:53         ` Kai Henningsen
2005-06-18 20:55 ` Robert Dewar
2005-06-18 22:45 ` Tristan Wibberley
2005-06-20 21:47 ` Mike Stump
  -- strict thread matches above, loose matches on Subject: below --
2005-06-17 12:00 Paul Schlie
2005-06-17 12:09 ` Paolo Bonzini
2005-06-17 18:29   ` Paul Schlie
2005-06-17 22:09     ` Paolo Bonzini
2005-06-17 22:48     ` Diego Novillo
2005-06-18  0:20       ` Paul Schlie
2005-06-18  0:23         ` Andrew Pinski
2005-06-18  0:59           ` Paul Schlie
2005-06-18  1:10             ` Dale Johannesen
2005-06-18  4:09             ` Mike Stump
     [not found]             ` <25364524.1119085038744.JavaMail.root@dtm1eusosrv72.dtm.ops.eu.uu.net>
2005-06-18 11:47               ` Toon Moene
2005-06-18  2:02         ` Robert Dewar
2005-06-17  4:28 Paul Schlie
2005-06-17  7:03 ` Paolo Bonzini
2005-06-17 12:28 ` Diego Novillo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=OF42B07BFE.4BCEC179-ON43257043.00260CD6-43257043.00271359@il.ibm.com \
    --to=veksler@il.ibm.com \
    --cc=dewar@adacore.com \
    --cc=gcc@gcc.gnu.org \
    --cc=kaih@khms.westfalen.de \
    --cc=sebastian.pop@cri.ensmp.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).