www.digitalmars.com         C & C++   DMDScript  

D - BUG ? duplicated ctors?

reply Ant <Ant_member pathlink.com> writes:
(let's try again with better subject. sorry for the (re)repetition)

this compiles with flag '-c':

class Dup
{
	this(){}
	this(char[] good){}
	this(char[] bad){}
}
void main()
{
	new Dup;
}

if the empty ctor is removed the compilation fails.
if the instanciation is removed, it compiles even without the empty ctor.

when adding to a lib a warning
"already in library, redefinition ignored" (the DM linker?)
is printed but seems the first one got in.

(the linux 
ar rcs libdui.a ....
doesn't throw any warning because of the 'r' in rcs)

(thanks to J C Calvarese for finding this on DUI)

Ant
Oct 15 2003
parent reply "Walter" <walter digitalmars.com> writes:
"Ant" <Ant_member pathlink.com> wrote in message
news:bmistk$22pm$1 digitaldaemon.com...
 (let's try again with better subject. sorry for the (re)repetition)

 this compiles with flag '-c':

 class Dup
 {
 this(){}
 this(char[] good){}
 this(char[] bad){}
 }
 void main()
 {
 new Dup;
 }

 if the empty ctor is removed the compilation fails.

Correct.
 if the instanciation is removed, it compiles even without the empty ctor.

Correct.
 when adding to a lib a warning
 "already in library, redefinition ignored" (the DM linker?)
 is printed but seems the first one got in.

Try removing the module from the library, and adding it again.
 (the linux
 ar rcs libdui.a ....
 doesn't throw any warning because of the 'r' in rcs)

 (thanks to J C Calvarese for finding this on DUI)

 Ant

Oct 17 2003
parent reply Ant <Ant_member pathlink.com> writes:
In article <bmoa28$3er$3 digitaldaemon.com>, Walter says...
"Ant" <Ant_member pathlink.com> wrote in message
news:bmistk$22pm$1 digitaldaemon.com...
 (let's try again with better subject. sorry for the (re)repetition)

 this compiles with flag '-c':

 class Dup
 {
 this(){}
 this(char[] good){}
 this(char[] bad){}
 }
 void main()
 {
 new Dup;
 }

 if the empty ctor is removed the compilation fails.

Correct.

Correct.

Sorry, the answer is too concise, I don't get it. Is that the expected behaviour of the compiler? a similar thing hapens with methods instead of ctors: void that(char[] good){}; void that(char[] bad){}; I would say this is a problem with the '-c' flag.(?) Or is it expected that the compiler doesn't check for duplicated methods with the '-c' flag? !!!! Ant
Oct 17 2003
parent "Walter" <walter digitalmars.com> writes:
"Ant" <Ant_member pathlink.com> wrote in message
news:bmosnj$rg2$1 digitaldaemon.com...
 In article <bmoa28$3er$3 digitaldaemon.com>, Walter says...
"Ant" <Ant_member pathlink.com> wrote in message
news:bmistk$22pm$1 digitaldaemon.com...
 (let's try again with better subject. sorry for the (re)repetition)

 this compiles with flag '-c':

 class Dup
 {
 this(){}
 this(char[] good){}
 this(char[] bad){}
 }
 void main()
 {
 new Dup;
 }

 if the empty ctor is removed the compilation fails.

Correct.

Correct.

Sorry, the answer is too concise, I don't get it. Is that the expected behaviour of the compiler? a similar thing hapens with methods instead of ctors: void that(char[] good){}; void that(char[] bad){};

Oh, I see now what's wrong. Sorry. It does look like a bug. -Walter
Oct 17 2003