 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Vincent Richard Guest
|
Posted: Tue Aug 19, 2003 10:36 am Post subject: [g++] Bug avec les itérateurs et -O3 ? |
|
|
Bonjour,
Pouvez-vous me dire si le code suivant est correct ?
Il compile avec g++ (aucune erreur, aucun avertissement), mais avec l'option
d'optimisation -O3, l'exécution produit une boucle infinie :
g++ -ansi -Wall -pedantic -o it it.cpp FONCTIONNE
g++ -O3 -ansi -Wall -pedantic -o it it.cpp NE FONCTIONNE PAS !!
Version de g++ :
g++ (GCC) 3.2.2 20030222 (Red Hat Linux 3.2.2-5)
Voici le code (it.cpp) :
#include <vector>
class A
{
public:
std::vector <int> v;
typedef std::vector <int>::iterator IT;
A()
{
for (int i = 0 ; i < 10 ; ++i)
{
v.push_back(i);
}
f(v.end() - 2);
}
const IT f(const IT i)
{
IT j = i - 1;
for (;
{
IT p = j;
p = j - 1;
j = p;
if (j == v.begin()) break;
}
return j;
}
};
int main()
{
A a;
}
Autre fait très étrange : si je déclare une variable "std::string s;" dans
la boucle (après la ligne "j = p"), l'exécution fonctionne dans les 2 cas...
Là, je comprends pas tout...
Merci d'avance pour vos réponses.
Vincent
--
SL> Au fait elle est mieux ma signature maintenant ?
Oui. T'enlève encore les conneries que t'as écrit dedans et c'est bon.
-+- JB in <http://www.le-gnu.net> : Le neuneuttoyage par le vide -+-
|
|
| Back to top |
|
 |
Richard Delorme Guest
|
Posted: Tue Aug 19, 2003 5:46 pm Post subject: Re: [g++] Bug avec les itérateurs et -O3 ? |
|
|
Vincent Richard a écrit :
| Quote: | Bonjour,
Pouvez-vous me dire si le code suivant est correct ?
|
Il m'a au moins l'air tordu.
| Quote: | Il compile avec g++ (aucune erreur, aucun avertissement), mais avec
l'option d'optimisation -O3, l'exécution produit une boucle infinie :
g++ -ansi -Wall -pedantic -o it it.cpp FONCTIONNE
g++ -O3 -ansi -Wall -pedantic -o it it.cpp NE FONCTIONNE PAS !!
Version de g++ :
g++ (GCC) 3.2.2 20030222 (Red Hat Linux 3.2.2-5)
|
ça ne marche pas non plus avec g++ 3.2.3, mais ça marche avec g++ 3.3.1. Il
s'agit sans doute d'un bogue corrigé.
--
Richard
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|