return string from inside if block => Segmentation Fault: 11
Alex Parrill via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Jun 1 09:54:58 PDT 2015
On Monday, 1 June 2015 at 16:52:30 UTC, Robert M. Münch wrote:
> I'm a bit confused... I have the following class:
>
> class foo : superFoo {
> aFoo spec;
> aFoo lvars;
> aFoo bdy;
>
> override string toString(){
> if(spec.isEmpty() && lvars.isEmpty()){
> return "does spec";
> }
>
> if(lvars.isEmpty()){
> return "funct spec";
> }
>
> return "function spec";
> }
> }
>
> The thing is, as soon as one if the IFs is true and the return
> statement is executed I get a seg-fault: 11
>
> If I comment the IFs it works. But I can't see any differences
> in returning from inside the if vs. the return at the end of
> the function.
>
> Any idea?
Are you sure that it's not the calls to `isEmpty`? Check if spec,
lvars, or anything that `isEmpty` uses are null.
More information about the Digitalmars-d-learn
mailing list