GNU C++ bug report
ExeBook Support
support@exebook.com
Sun Apr 8 03:27:00 GMT 2001
I am using "gcc, g++ - GNU project C and C++ Compiler (gcc-2.95.1)"
the one shiped with my FreeBSD 4.2
The following code (see below) produces the incorrect output binary.
The problem is that the constructor is called once and the destructor is
called twice.
Three other compilers I used to compile this example give the correct result
(i.e. both the desctuctor and constructro are called once). Those compilers
are Borland C++ builder 5.0, MSVC 6.0 and GNU C++ shipped with Mingw.
Also the bug appears on the gcc shipped with FreeBSD 3.4 and theone shipped
with latest OpenBSD (not sure which version).
People keep telling me not to use such constructions in my programs, but c++
reference allows it, so I think I should let you know the problem persist.
If it is possible replyme with comments or let me know when the bug is fixed
orjust ell me it is already fixed and I just need a newer version of gcc.
Thank you.
Yakov Sudeikin
#include <stdlib.h>
#include <stdio.h>
class err {
public:
~err()
{
printf("~err()\n");
};
err(int i) { printf("err();"); };
};
void error(err e)
{
printf("test\n");
};
void main()
{
error(2);
};
More information about the Gcc
mailing list