This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

2.95.2 19991024 (release), Next 3.3; -fno-elide-constructors isscrewed up


In program below, there are three problems with -felide-constructors:

1) It is on by default
2) It can't be turned off
3) It accepts erroneous constructs.

In sample program below, A a = a is treated like A a(a) and core dumps on  
execution. A a(a) by itself results in a compilation error. A a = a beats the  
compilation error.

If -felide-constructors is allowed to have such dangerous behavior, it  
should be off by default.

#include <string>


class A
{
private:

    // Not implemented
    A& operator=(const A& other);

public:

    A(const A& other);

    virtual ~A(void);

private:

    string _str;
};


A::

A(const A& other)
    :
    _str(other._str)
{
}


A::

~A(void)
{
}


int

main(void)
{
    A a = a;

    return 0;
}

maskull:temp>g++ -v -ansi -pedantic -W -Wall -fno-elide-constructors -o  
elide elide.cc
Reading specs from /usr/local/lib/gcc-lib/m68k-next-nextstep3/2.95.2/specs
Reading specs from /usr/local/lib/gcc-lib/m68k-next-nextstep3/specs
gcc driver version 2.95.2 19991024 (release) executing gcc version egcs-2.91.53
 /usr/local/lib/gcc-lib/m68k-next-nextstep3/2.95.2/cpp -lang-c++ -v  
-D__GNUC__=2 -D__GNUG__=2 -D__GNUC_MINOR__=91 -D__cplusplus -trigraphs  
-D__STRICT_ANSI__ -D__mc68000__ -D__m68k__ -D__NeXT__ -D__unix__ -D__MACH__  
-D__BIG_ENDIAN__ -D__ARCHITECTURE__="m68k" -D_NEXT_SOURCE -D__mc68000  
-D__m68k -D__NeXT -D__unix -Asystem(unix) -Asystem(mach) -Acpu(m68k)  
-Amachine(m68k) -D__EXCEPTIONS -W -Wall -pedantic -D__STDC__ elide.cc  
/usr/tmp/ccC8eAic.ii
GNU CPP version 2.95.2 19991024 (release) (68k, MIT syntax)
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/lib/gcc-lib/m68k-next-nextstep3/2.95.2/../../../../include/g++-3
 /usr/local/include
  
/usr/local/lib/gcc-lib/m68k-next-nextstep3/2.95.2/../../../../m68k-next-nextstep3/include
 /usr/local/lib/gcc-lib/m68k-next-nextstep3/2.95.2/include
 /usr/local/lib/gcc-lib/m68k-next-nextstep3/2.95.2/include/ansi
 /usr/local/lib/gcc-lib/m68k-next-nextstep3/2.95.2/include/bsd
 /NextDeveloper/Headers
 /NextDeveloper/Headers/ansi
 /NextDeveloper/Headers/bsd
 /LocalDeveloper/Headers
 /NextDeveloper/2.0CompatibleHeaders
 /usr/include
 /usr/include/bsd
End of search list.
The following default directories have been omitted from the search path:
 /LocalDeveloper/Headers/ansi
 /LocalDeveloper/Headers/bsd
End of omitted list.
 /usr/local/lib/gcc-lib/m68k-next-nextstep3/2.95.2/cc1plus  
/usr/tmp/ccC8eAic.ii -quiet -dumpbase elide.cc -W -Wall -pedantic -ansi  
-version -fno-elide-constructors -o /usr/tmp/ccDnwg0X.s
GNU C++ version 2.95.2 19991024 (release) (m68k-next-nextstep3) compiled by  
GNU C version 2.95.2 19991024 (release).
 /usr/local/m68k-next-nextstep3/bin/as -o /usr/tmp/ccCNz9xz.o /usr/tmp/ccDnwg0X.s
 /usr/local/lib/gcc-lib/m68k-next-nextstep3/2.95.2/collect2 -o elide  
-lcrt0.o -L/usr/local/lib/gcc-lib/m68k-next-nextstep3/2.95.2  
-L/usr/local/m68k-next-nextstep3/lib -L/usr/local/lib /usr/tmp/ccCNz9xz.o  
-lstdc++ -lm -lgcc -lsys_s -lgcc
maskull:temp>

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]