--- Begin Message ---
Subject: |
Re: bug#14572: Goto Label Bug |
Date: |
Fri, 07 Jun 2013 17:16:32 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
Shane Celis <address@hidden> writes:
> If a goto label is followed by an SCM variable declaration, a
> compilation error will result. I've written up this piece of code
> that demonstrates the behavior and how to work around it, available
> here:
>
> https://gist.github.com/shanecelis/5728982
In the future, please send the relevant information as attachments, so
that it's recorded in our bug tracking system. For posterity, here it
is:
--8<---------------cut here---------------start------------->8---
/*
This file demonstrates a bug with C goto labels and Guile.
$ gcc `pkg-config guile-2.0 --cflags --libs` goto_label_bug.c -o goto_label_bug
goto_label_bug.c: In function 'main':
goto_label_bug.c:10: error: expected expression before 'SCM'
$ gcc `pkg-config guile-2.0 --cflags --libs` goto_label_bug.c -o goto_label_bug
-D INSERT_NOOP
$ # No problem.
Shane Celis
*/
#include <libguile.h>
int main(int argc, char *argv[]) {
scm_init_guile();
goto end;
end:
#ifdef INSERT_NOOP
; /* No error with dummy statement. */
#endif
SCM dummy = SCM_BOOL_T; /* Causes error. */
return 0;
}
--8<---------------cut here---------------end--------------->8---
This is unrelated to Guile. The same problem happens with GCC 4.7 if
you make the following substitutions:
libguile.h --> stdio.h
scm_init_guile() --> printf ("Test\n");
SCM --> int
SCM_BOOL_T --> 0
However, in that case the error message is more helpful:
error: a label can only be part of a statement and a declaration is not a
statement
Indeed, C99 section 6.8.1 specifies that labels may only precede
statements.
Regards,
Mark
--- End Message ---