C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Erreur bizarre

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ (French)
View previous topic :: View next topic  
Author Message
Vincent Richard
Guest





PostPosted: Tue Jul 15, 2003 3:03 pm    Post subject: Erreur bizarre Reply with quote



Bonjour,

Quelqu'un peut-il m'expliquer pourquoi j'obtiens une erreur de compilation
avec le programme suivant (voir plus bas) ?

[vincent@Sherlock tmp]$ g++ -ansi -Wall -pedantic -o prob prob.cpp
prob.cpp: Dans constructor « A::A() »:
prob.cpp:57: erreur d'analyse syntaxique avantle jeton « ; »
prob.cpp:58: rendu confus par les erreurs précédentes, abandon

[vincent@Sherlock tmp]$ g++ --version
g++ (GCC) 3.2.2 20030222 (Red Hat Linux 3.2.2-5)


Voici le code :


#include <string>

class S
{
public:

static S* getInstance() { return (inst ? inst : (inst = new S)); }

const std::string& get() const { return str; }

private:

S() { }
~S() { }

static S* inst;
std::string str;
};

S* S::inst = NULL;


class T
{
public:

T(const std::string& s) { str = s; }

inline operator const std::string&() { return (str); }

private:

std::string str;
};


class M
{
public:

M(const std::string &s) { /* ... */ }
};


class A
{
public:

A()
{
// OK Smile
const std::string& s = S::getInstance()->get();
M m1(T(s));

// KO Sad
M m2(T(S::getInstance()->get())); // ligne 57
}
};


int main()
{
A a;
}


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
Jean-Marc Bourguet
Guest





PostPosted: Tue Jul 15, 2003 3:12 pm    Post subject: Re: Erreur bizarre Reply with quote



Vincent Richard <chere-loque.MARRE-DE-LA-PUB (AT) wanadoo (DOT) fr.invalid> writes:

Quote:
Quelqu'un peut-il m'expliquer pourquoi j'obtiens une erreur de compilation
avec le programme suivant (voir plus bas) ?

Bug dans gcc vraissemblablement (toujours present dans gcc 3.3). Je
ne vois pas de probleme et ca passe avec como
(http://www.comeaucomputing.com/pcgi-bin/compiler.html) et sun CC.
C'est toujours bien d'essayer un autre compilateur quand on ne
comprend pas le probleme et le "Test Drive Comeau C/C++ Online" est
pratique pour ca.

A+

--
Jean-Marc
FAQ de fclc++: http://www.cmla.ens-cachan.fr/~dosreis/C++/FAQ
C++ FAQ Lite en VF: http://www.ifrance.com/jlecomte/c++/c++-faq-lite/index.html
Site de usenet-fr: http://www.usenet-fr.news.eu.org

Back to top
Gabriel Dos Reis
Guest





PostPosted: Tue Jul 15, 2003 3:38 pm    Post subject: Re: Erreur bizarre Reply with quote



Vincent Richard <chere-loque.MARRE-DE-LA-PUB (AT) wanadoo (DOT) fr.invalid> writes:


Quote:
prob.cpp:57: erreur d'analyse syntaxique avantle jeton « ; »

Tien, je ne savais pas que dans ce contexte, ils traduiraient toekn
par jeton.

[...]

Quote:
// OK Smile
const std::string& s = S::getInstance()->get();
M m1(T(s));

Ceci est une déclaration de fonction nommée m1 prenant un T et
retournant un M -- le paramètre formel se nomme s, qui n'a rien à
avoir avec la ligne au dessus.

Quote:
// KO Sad
M m2(T(S::getInstance()->get())); // ligne 57

Toutes les version courantes de GCC en production (i.e. précédant
GCC-3.4) ont des problèmes pour parser une construction.

-- Gaby

Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ (French) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.