found an issue in testsuite/libgomp.c++/for-3.C

Martin Ettl ettl.martin@gmx.de
Tue Jul 28 20:39:00 GMT 2009


I am not shur, if it is bug in cppcheck or not. I created a ticket on the bugtracker of cppcheck.

https://sourceforge.net/apps/trac/cppcheck/ticket/525

Best regards

Martin

-------- Original-Nachricht --------
> Datum: Mon, 27 Jul 2009 23:27:45 -0700
> Von: Andrew Pinski <pinskia@gmail.com>
> An: Martin Ettl <ettl.martin@gmx.de>
> CC: "gcc-testresults@gcc.gnu.org" <gcc-testresults@gcc.gnu.org>
> Betreff: Re: found an issue in testsuite/libgomp.c++/for-3.C

> 
> 
> Sent from my iPhone
> 
> On Jul 27, 2009, at 10:54 PM, "Martin Ettl" <ettl.martin@gmx.de> wrote:
> 
> > hello,
> >
> > i have checked the sources of g++-4.4.1 with the static code  
> > analysis tool cppcheck. It found an issue in file gcc-4.4.1/libgomp/ 
> > testsuite/libgomp.c++/for-3.C at line 49.
> >
> > I brought the following warning:
> > vector range should use != and not < since the order of the pointers  
> > is not guaranteed.
> 
> Huh? The order of pointers is defined if they belong to the same  
> array. In this case there is no pointer comparison. We are invoking  
> operator< on the iterator class. Which is obviously only defined if  
> they point to the same vector.  So I think the static analyizer is  
> incorrect.
> 
> 
> 
> >
> > Take a look at the code:
> >
> > void
> > f2 (const std::vector<int>::const_iterator &x,
> >    const std::vector<int>::const_iterator &y)
> > {
> >  std::vector<int>::const_iterator i;
> > #pragma omp parallel for private(i)
> >  for (i = x; i < y - 1; i = 1 - 6 + 7 + i)
> >    baz (i);
> > }
> >
> > Indeed, the static code analysis tool is right. It would be better  
> > to compare the pointers with the !=-operator not with '<'.
> >
> > Best regards
> >
> > Ettl Martin
> >
> >
> >
> > -- 
> > Jetzt kostenlos herunterladen: Internet Explorer 8 und Mozilla  
> > Firefox 3 -
> > sicherer, schneller und einfacher! http://portal.gmx.net/de/go/chbrowser

-- 
Jetzt kostenlos herunterladen: Internet Explorer 8 und Mozilla Firefox 3 -
sicherer, schneller und einfacher! http://portal.gmx.net/de/go/atbrowser



More information about the Gcc-testresults mailing list