Package: valac-0.10
Version: 0.10.4-1
Severity: normal
Tags: upstream fixed-upstream

Hi,

vala 0.10 doesn't handle fixed-size arrays correctly as it still thinks
they need to freed after use. With the attached minimal bindings for
pulseaudio and a simple test program, I get this:

        $ valac-0.10 --vapidir=. --pkg=libpulse Test.vala 
        Test.vala:2.2-2.26: warning: field `Test.map' never used
                PulseAudio.ChannelMap map;
                ^^^^^^^^^^^^^^^^^^^^^^^^^
        /tmp/ccJ40C4Z.o: In function `test_finalize':
        Test.vala.c:(.text+0x152): undefined reference to 
`pulse_audio_channel_map_destroy'
        collect2: ld returned 1 exit status
        error: cc exited with status 256
        Compilation failed: 1 error(s), 1 warning(s)
        $ 

vala 0.12 behaves correctly:

        $ valac-0.12 --vapidir=. --pkg=libpulse Test.vala 
        Test.vala:2.2-2.26: warning: field `Test.map' never used
                PulseAudio.ChannelMap map;
                ^^^^^^^^^^^^^^^^^^^^^^^^^
        Compilation succeeded - 1 warning(s)
        $ 

I guess that one of these [1] commits fixed the issue. If you have to
use vala 0.10, you can use something like this as a workaround (thanks
to Sean McNamara![2]):

        $ diff -u libpulse.vapi.old libpulse.vapi
        --- libpulse.vapi.old   2011-04-14 16:43:04.177836648 +0200
        +++ libpulse.vapi       2011-04-14 16:43:27.258335636 +0200
        @@ -1,6 +1,6 @@
         [CCode (cheader_filename="pulse/pulseaudio.h")]
         namespace PulseAudio {
        -        [CCode (cname="pa_channel_map")]
        +        [CCode (cname="pa_channel_map", has_destroy_function=false)]
                 public struct ChannelMap {
                         public uint8 channels;
                         public ChannelPosition map[32];
        $ valac-0.10 --vapidir=. --pkg=libpulse Test.vala 
        Test.vala:2.2-2.26: warning: field `Test.map' never used
                PulseAudio.ChannelMap map;
                ^^^^^^^^^^^^^^^^^^^^^^^^^
        Compilation succeeded - 1 warning(s)
        $ 

There is no need to take any action about this since the bug is fixed in
the latest upstream stable release, but I wanted to document it here for
later reference. If I have some spare time, I might try to exactly
pinpoint the fix and backport it to vala 0.10, so please don't close
this bug report for now.

Best regards

Alexander Kurtz

[1] http://git.gnome.org/browse/vala/log/?qt=grep&q=fixed.*array
[2] 
https://tango.0pointer.de/pipermail/pulseaudio-discuss/2011-March/009695.html
[CCode (cheader_filename="pulse/pulseaudio.h")]
namespace PulseAudio {
        [CCode (cname="pa_channel_map")]
        public struct ChannelMap {
                public uint8 channels;
                public ChannelPosition map[32];
        }

        [CCode (cname="pa_channel_position_t", cprefix="PA_CHANNEL_POSITION_")]
        public enum ChannelPosition {
                INVALID
        }
}
class Test : Object {
	PulseAudio.ChannelMap map;
	public static void main(){
	}
}

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to