Topic: Exception Bug in MSVC?
Author: Philip Tarpley <ptarp@wworld.com>
Date: 2000/11/21 Raw View
This code seems to compile fine in MSVC ver 6, although I think it
should produce an error.
//...includes...
void f(void) throw(int); //Can throw int exceptions
void (*pf1)(void) throw(); //Can't throw exceptions at all
void main(void)
{
pf1 = &f; //Should give compile time error because pf1
//is more restrictive than f() is?
pf1(); //Works fine in MSVC ver 6(with the updates)
}
void f(void)throw(int)
{
cout << "f() called\n" ;
throw(9);
}
Any info regarding the code would be appreciated.
Philip Tarpley
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html ]
[ Note that the FAQ URL has changed! Please update your bookmarks. ]
Author: "Richard Parkin" <rparkin@nospam.msi-eu.com>
Date: 2000/11/21 Raw View
"Philip Tarpley" <ptarp@wworld.com> wrote in message
news:3A19B14B.D2363CF0@wworld.com...
> This code seems to compile fine in MSVC ver 6, although I think it
> should produce an error.
>
> file://...includes...
>
> void f(void) throw(int); file://Can throw int exceptions
> void (*pf1)(void) throw(); file://Can't throw exceptions at all
This would give a warning (at level 4?) saying something along the lines of
'exception specifications not supported, so yah boo sucks'.
> void main(void)
#include <stdmoan> // return type is int
> {
> pf1 = &f; file://Should give compile time error because pf1
> file://is more restrictive than f() is?
>
> pf1(); file://Works fine in MSVC ver 6(with the updates)
> }
According to 15.4/3, your rationale is right. But MSVC ignores exception
specs.
Ric
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html ]
[ Note that the FAQ URL has changed! Please update your bookmarks. ]
Author: Francis Glassborow <francis.glassborow@ntlworld.com>
Date: 2000/11/21 Raw View
In article <3A19B14B.D2363CF0@wworld.com>, Philip Tarpley
<ptarp@wworld.com> writes
>This code seems to compile fine in MSVC ver 6, although I think it
>should produce an error.
>
>//...includes...
>
>void f(void) throw(int); //Can throw int exceptions
>void (*pf1)(void) throw(); //Can't throw exceptions at all
>
>void main(void)
^^^^
But, if it were an attempt to meet the C++ standard it would produce a
diagnostic for the void return from main.
>{
> pf1 = &f; //Should give compile time error because pf1
> //is more restrictive than f() is?
As it has already ignored the standard once, why expect it to be more
punctilious here?
>
> pf1(); //Works fine in MSVC ver 6(with the updates)
>}
Francis Glassborow Association of C & C++ Users
64 Southfield Rd
Oxford OX4 1PA +44(0)1865 246490
All opinions are mine and do not represent those of any organisation
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html ]
[ Note that the FAQ URL has changed! Please update your bookmarks. ]
Author: Pete Becker <petebecker@acm.org>
Date: 2000/11/21 Raw View
Richard Parkin wrote:
>
> According to 15.4/3, your rationale is right. But MSVC ignores exception
> specs.
>
15.4/3 is about virtual functions. There are no virtual functions here.
--
Pete Becker
Dinkumware, Ltd. (http://www.dinkumware.com)
Contributing Editor, C/C++ Users Journal (http://www.cuj.com)
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html ]
[ Note that the FAQ URL has changed! Please update your bookmarks. ]
Author: Pete Becker <petebecker@acm.org>
Date: 2000/11/21 Raw View
Pete Becker wrote:
>
> Richard Parkin wrote:
> >
> > According to 15.4/3, your rationale is right. But MSVC ignores exception
> > specs.
> >
>
> 15.4/3 is about virtual functions. There are no virtual functions here.
>
Whoops, never mind. 15.4/3 talks about two different subjects.
--
Pete Becker
Dinkumware, Ltd. (http://www.dinkumware.com)
Contributing Editor, C/C++ Users Journal (http://www.cuj.com)
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html ]
[ Note that the FAQ URL has changed! Please update your bookmarks. ]