[Bug c/69704] New: goto *42 is not diagnosed
Keith.S.Thompson at gmail dot com
gcc-bugzilla@gcc.gnu.org
Sat Feb 6 04:21:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69704
Bug ID: 69704
Summary: goto *42 is not diagnosed
Product: gcc
Version: 5.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: Keith.S.Thompson at gmail dot com
Target Milestone: ---
This program:
int main(void) {
goto *(void*)42;
}
shows a legal use of gcc's computed goto extension.
This program:
int main(void) {
goto *42;
}
results in the same generated machine code, but is not consistent with the
documented extension, which permits the expression following "goto *" to be of
type void*. (An int value can be converted to void*, but only via an explicit
cast, or in the special case of a null pointer constant.)
The expression *42 by itself is correctly diagnosed as an error.
$ uname -a
Linux bomb20 3.16.0-38-generic #52~14.04.1-Ubuntu SMP Fri May 8 09:43:57 UTC
2015 x86_64 GNU/Linux
$ gcc --version
gcc (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4
This was inspired by this question on Stack Overflow:
http://stackoverflow.com/q/35236834/827263
posted by user Sarvadi.
More information about the Gcc-bugs
mailing list