🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Dean R. E. Long Tue, 26 Jan 1993 01:05
"trivial conversion" bug
#1407
Author: Dean R. E. Long
Date: Tue, 26 Jan 1993 01:05
52 lines
2106 bytes
In this example, should not the trivial conversion (const T --> const T &)
be applied before the user-defined conversion?

--
arapaho /tmp [61] % cat a.c
#include <stream.h>

class A {
public:
    A(int)      {}
    operator const A & (void) const
    {
        cout << "Converted to (const A &) !\n";
        return *this;
    }
    operator == (const A &a) const
    {
        return 1;
    }
};

main()
{
    const A a = 0, b = 0;

    return a == b;
}
arapaho /tmp [62] % g++ -v a.c
Reading specs from /usr/local/gnu/lib/gcc-lib/sparc-sun-sunos4.1.2/2.3.3/specs
gcc version 2.3.3
 /usr/local/gnu/lib/gcc-lib/sparc-sun-sunos4.1.2/2.3.3/cpp -lang-c++ -v -undef -
D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -Dsparc -Dsun -Dunix -D__sparc__ -D__sun_
_ -D__unix__ -D__sparc -D__sun -D__unix a.c /usr/tmp/cca19255.i
GNU CPP version 2.3.3 (sparc)
 /usr/local/gnu/lib/gcc-lib/sparc-sun-sunos4.1.2/2.3.3/cc1plus /usr/tmp/cca19255
.i -quiet -dumpbase a.cc -version -o /usr/tmp/cca19255.s
GNU C++ version 2.3.3 (sparc) compiled by GNU C version 2.3.3.
 as -o /usr/tmp/cca192551.o /usr/tmp/cca19255.s
 /usr/local/gnu/lib/gcc-lib/sparc-sun-sunos4.1.2/2.3.3/ld -e start -dc -dp /lib/
crt0.o -L/usr/local/gnu/lib/gcc-lib/sparc-sun-sunos4.1.2/2.3.3 -L/usr/local/gnu/
lib /usr/tmp/cca192551.o -lg++ -lgcc -lc -lgcc
arapaho /tmp [63] % a.out
Converted to (const A &) !
Converted to (const A &) !
Converted to (const A &) !
Converted to (const A &) !
Converted to (const A &) !
Converted to (const A &) !
Converted to (const A &) !
Converted to (const A &) !
Converted to (const A &) !
[repeated forever...]
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads