After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 692019 - constructor can't be chained from 'if'
constructor can't be chained from 'if'
Status: RESOLVED OBSOLETE
Product: vala
Classification: Core
Component: Methods
0.18.x
Other Linux
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2013-01-18 16:39 UTC by Ilya Mezhirov
Modified: 2018-05-22 14:40 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
valac foo.vala; ./foo -> Segmentation fault (247 bytes, text/x-vala)
2013-01-18 16:39 UTC, Ilya Mezhirov
Details

Description Ilya Mezhirov 2013-01-18 16:39:54 UTC
Created attachment 233770 [details]
valac foo.vala; ./foo   -> Segmentation fault

$ valac --version
Vala 0.18.1

A problem arises when a chain constructor call is inside an if.
This code gives segmentation fault.
_________________________

class Foo
{
    int x;

    public Foo()
    {
        x = 1;
    }

    public Foo.maybe_chain(bool chain)
    {
        if (chain)
            this();
        x = 3;
        print("b\n");
    }
}

void main()
{
    new Foo.maybe_chain(false);
}

_________________________

The compiler only creates self inside if:
        if (_tmp0_) {
                self = (Foo*) foo_construct (object_type);
        }
Comment 1 GNOME Infrastructure Team 2018-05-22 14:40:17 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/vala/issues/350.