Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
March 05, 2006 auto declaration & compiler warning "no function return" | ||||
---|---|---|---|---|
| ||||
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 |
March 05, 2006 Re: auto declaration & compiler warning | ||||
---|---|---|---|---|
| ||||
Posted in reply to akcom | 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 |
March 05, 2006 Re: auto declaration & compiler warning "no function return" | ||||
---|---|---|---|---|
| ||||
Posted in reply to akcom | 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 |
Copyright © 1999-2021 by the D Language Foundation