public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: Phil Edwards <phil@jaj.com>
To: nobody@gcc.gnu.org
Cc: gcc-prs@gcc.gnu.org,
Subject: Re: libstdc++/7972: > v.size(), where v is vector, incorrectly returns true
Date: Wed, 18 Sep 2002 16:36:00 -0000	[thread overview]
Message-ID: <20020918233601.31330.qmail@sources.redhat.com> (raw)

The following reply was made to PR libstdc++/7972; it has been noted by GNATS.

From: Phil Edwards <phil@jaj.com>
To: nathan.holladay@utsouthwestern.edu
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: libstdc++/7972: > v.size(), where v is vector, incorrectly returns true
Date: Wed, 18 Sep 2002 19:29:14 -0400

 On Wed, Sep 18, 2002 at 04:13:29PM -0000, nathan.holladay@utsouthwestern.edu wrote:
 > >Description:
 > (I am not sure about what the Submitter-Id is.)
 
 It's handled automatically if you use the normal bug reporting mechanisms.
 (And you did.)
 
 > It appears that a program will incorrectly return true at least for
 > an if statement, if(i > v.size()) where i is an integer of some value
 > less than the size of a vector, v. This exact same problem is found in
 > Microsoft's Visual C++ 6.0 compiler. I also reported it to them, and noted
 > the co-existence in the gnu compiler. (It is hard not to conclude that
 > someone copied from someone else,
 
 Faulty logic.  The only common code in this case is /yours/.  :-)
 
 
 > (I am suspecting that the '>' operator is simply overloaded improperly
 > for whatever type vector::size() returns.)
 
 There's no overloading.  The type involved will be something like
 "unsigned int".
 
     % g++-3.2 -Wall -W pr.cc
     pr.cc:8: warning: ISO C++ forbids declaration of `main' with no type
     pr.cc: In function `int main()':
 ->  pr.cc:14: warning: comparison between signed and unsigned integer expressions
     %
 
 Declare structnumber as "std::vector<double>::size_type" instead of int,
 and you won't have this problem.  (Yes, some typedefs will help you
 reducing typing.)
 
 
 Phil
 
 -- 
 I would therefore like to posit that computing's central challenge, viz. "How
 not to make a mess of it," has /not/ been met.
                                                  - Edsger Dijkstra, 1930-2002


             reply	other threads:[~2002-09-18 23:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-09-18 16:36 Phil Edwards [this message]
  -- strict thread matches above, loose matches on Subject: below --
2002-10-02 19:57 pme
2002-09-18  9:16 nathan.holladay

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=20020918233601.31330.qmail@sources.redhat.com \
    --to=phil@jaj.com \
    --cc=gcc-prs@gcc.gnu.org \
    --cc=nobody@gcc.gnu.org \
    /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).