www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - auto declaration & compiler warning "no function return"

reply akcom <CppCoder gmail.com> writes:
private void onRead()
{
	...
	auto InternetHost ih = new InternetHost();
	if ( ih.getHostByAddr( ia.addr() ) )
	{
		//remember to delete this!!
		hostName = ih.name.dup;
	}
	else
	{
		hostName = "unknown";
	}
	...
	return true;
}

compiler gives the following: "warning - peer.d(342): function 
akp2p.peer.Peer.onRead no return at end of function"

but when I remove the "auto" from the ih declaration, everything 
compiles as expected
Mar 05 2006
next sibling parent Stu <Stu_member pathlink.com> writes:
Don't know what the rest of the code's doing but this compiles ok for me
(DMD.148). Can you give us more of your code to get a small full example which
reproduces the error? 

import std.stdio;
import std.socket;

void main()
{
Test t = new Test();
}

class Test
{
private InternetAddress ia;
private char[] hostName;
private void onRead()
{
auto InternetHost ih = new InternetHost();
if ( ih.getHostByAddr( ia.addr() ) )
{
//remember to delete this!!
hostName = ih.name.dup;
}
else
{
hostName = "unknown";
}
return true;
}
}

Stu 

In article <dufjl2$11dh$1 digitaldaemon.com>, akcom says...
private void onRead()
{
	...
	auto InternetHost ih = new InternetHost();
	if ( ih.getHostByAddr( ia.addr() ) )
	{
		//remember to delete this!!
		hostName = ih.name.dup;
	}
	else
	{
		hostName = "unknown";
	}
	...
	return true;
}

compiler gives the following: "warning - peer.d(342): function 
akp2p.peer.Peer.onRead no return at end of function"

but when I remove the "auto" from the ih declaration, everything 
compiles as expected

Mar 05 2006
prev sibling parent Brad Roberts <braddr puremagic.com> writes:
On Sun, 5 Mar 2006, akcom wrote:

 private void onRead()
 {
 	...
 	auto InternetHost ih = new InternetHost();
 	if ( ih.getHostByAddr( ia.addr() ) )
 	{
 		//remember to delete this!!
 		hostName = ih.name.dup;
 	}
 	else
 	{
 		hostName = "unknown";
 	}
 	...
 	return true;
 }
 
 compiler gives the following: "warning - peer.d(342): function
 akp2p.peer.Peer.onRead no return at end of function"
 
 but when I remove the "auto" from the ih declaration, everything compiles as
 expected

I'm fairly sure this is a dup of: http://d.puremagic.com/bugzilla/show_bug.cgi?id=5 I've got a potential patch for it in the bug which I just reassigned to walter. Later, Brad
Mar 05 2006