[Vala] wrong code generated with thread function
- From: "Colombo, Alberto" <A Colombo kingston ac uk>
- To: "vala-list gnome org" <vala-list gnome org>
- Subject: [Vala] wrong code generated with thread function
- Date: Mon, 28 Sep 2009 14:29:20 +0100
Hello,
I'm using valac 0.7.7 and the following small example is compiled into erroneous C code:
class BrokenThread
{
void *a_method()
{
while (true)
{
Thread.usleep(1000000);
}
return null;
}
public static void main(string[] args)
{
var inst = new BrokenThread();
try {
Thread.create(inst.a_method, false);
} catch (ThreadError e){}
}
}
The compiler output is:
BrokenThread.vala:9.9-9.20: warning: unreachable code detected
return null;
^^^^^^^^^^^^
/home/albx/Projects/tests/BrokenThread.vala.c: In function ‘broken_thread_a_method’:
/home/albx/Projects/tests/BrokenThread.vala.c:67: error: ‘result’ undeclared (first use in this function)
/home/albx/Projects/tests/BrokenThread.vala.c:67: error: (Each undeclared identifier is reported only once
/home/albx/Projects/tests/BrokenThread.vala.c:67: error: for each function it appears in.)
In fact, the generated ‘broken_thread_a_method’ is like this:
static void* broken_thread_a_method (BrokenThread* self) {
g_return_val_if_fail (self != NULL, NULL);
while (TRUE) {
g_usleep ((gulong) 1000000);
}
result = NULL;
return result;
}
Regards
Alberto
This email has been scanned for all viruses by the MessageLabs Email
Security System.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]