 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Fabien SK Guest
|
Posted: Thu Aug 07, 2003 3:05 pm Post subject: throw sans paramètre |
|
|
Bonjour,
J'ai constaté avec surprise que le bout de code suivant compile avec VC6
(qui n'est pas une référence du respect des standards) et avec g++ 3.2
(avec "-Wall -ansi -pedantic"):
void doit()
{
throw;
}
Mais quel peut-il bien se passer dans le cas où la fonction "doit" n'est
pas appelée dans un bloc "catch" ? Une exception de type inconnu,
attrapable uniquement par un "catch(...)" ?
Fabien
|
|
| Back to top |
|
 |
Patrick Mézard Guest
|
Posted: Thu Aug 07, 2003 5:44 pm Post subject: Re: throw sans paramètre |
|
|
| Quote: | void doit()
{
throw;
}
Mais quel peut-il bien se passer dans le cas où la fonction "doit" n'est
pas appelée dans un bloc "catch" ? Une exception de type inconnu,
attrapable uniquement par un "catch(...)" ?
Fabien
|
Ca appelle std::terminate, il me semble.
Patrick Mézard
|
|
| Back to top |
|
 |
Fabien SK Guest
|
Posted: Fri Aug 08, 2003 9:21 am Post subject: Re: throw sans paramètre |
|
|
Patrick Mézard wrote:
| Quote: | void doit()
{
throw;
}
Mais quel peut-il bien se passer dans le cas où la fonction "doit" n'est
pas appelée dans un bloc "catch" ? Une exception de type inconnu,
attrapable uniquement par un "catch(...)" ?
Fabien
Ca appelle std::terminate, il me semble.
Patrick Mézard
|
Oui, ça je savais déjà qu'une exception non attrapée provoque l'appel de
"std::terminate" Mais la question était: quel est ce type
d'exception. Si je fais:
int main(int argc, char *argv)
{
try
{
throw;
}
catch(...)
{
// quel est le type de l'exception ici ? ?
}
}
Le "throw" n'a pas pu redéclencher une exception existante....
Fabien
|
|
| 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
|
|