Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug
Bug#: 38725
Product:  
Component:  
Status: RESOLVED
Resolution: FIXED
Assigned To: Jakub Jelinek <jakub@gcc.gnu.org>
Host:
Reported against  
Priority:  
Severity:  
Target Milestone:  
 
 
Target:
Reporter: Volker Reichelt <reichelt@gcc.gnu.org>
Add CC:
CC:
Remove selected CCs
Build:
Patch URL:
Summary:
Keywords:
Known to work:
Known to fail:

Attachment Description Type Created Size Actions
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 38725 depends on: Show dependency tree
Show dependency graph
Bug 38725 blocks:

Additional Comments:






View Bug Activity   |   Format For Printing   |   Clone This Bug


Description:   Last confirmed: 2009-01-07 22:56 Opened: 2009-01-04 22:07
The following code snippet triggers an ICE on the trunk:

=====================
void foo(int i)
{
  goto *i;
}
=====================

bug.cc: In function 'void foo(int)':
bug.cc:1: error: goto destination is neither a label nor a pointer
goto i;

bug.cc:1: internal compiler error: verify_gimple failed
Please submit a full bug report, [etc.]

The error message comes from verify_gimple_goto so this is not an
error-recovey bug, but a crash in the middle-end.

I'm not quite sure whether the code is valid or not, i.e. whether 'i'
should be converted into a pointer automatically or not.
The C frontend accepts the code. The C++ frontend accepted the code up
to and including 4.3.x.


A more complex (and definitely invalid) testcase crashes in a different
position (since at least GCC 2.95.3):

==========================
struct A {};

struct B : virtual A {};

void foo(B b)
{
  goto *b;
}
==========================

bug.cc: In function 'void foo(B)':
bug.cc:7: internal compiler error: in create_tmp_var, at gimplify.c:555
Please submit a full bug report, [etc.]

------- Comment #1 From Richard Guenther 2009-01-04 23:04 -------
IMHO this is invalid.  extend.texi says

@smallexample
goto *ptr;
@end smallexample

@noindent
Any expression of type @code{void *} is allowed.

and integers are not promoted to pointers.

This checking is only enabled with checking.

------- Comment #2 From Jakub Jelinek 2009-01-04 23:38 -------
The C FE converts this to void * pointer silently:
7168 tree
7169 c_finish_goto_ptr (tree expr)
7170 {
7171   pedwarn (input_location, OPT_pedantic, "ISO C forbids %<goto *expr;%>");
7172   expr = convert (ptr_type_node, expr);
7173   return add_stmt (build1 (GOTO_EXPR, void_type_node, expr));
7174 }
but the C++ FE doesn't.  Either C++ should do the same as C, or both should
reject it.

------- Comment #3 From joseph@codesourcery.com 2009-01-05 05:05 -------
Subject: Re:  [4.4 regression] ICE with goto

This being accepted for C is bug 32122.

------- Comment #4 From Volker Reichelt 2009-01-05 21:48 -------
*** Bug 38593 has been marked as a duplicate of this bug. ***

------- Comment #5 From Jakub Jelinek 2009-01-08 00:24 -------
Subject: Bug 38725

Author: jakub
Date: Thu Jan  8 00:23:48 2009
New Revision: 143177

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=143177
Log:
        PR c++/38725
        * semantics.c (finish_goto_stmt): Convert destination to
        void *.

        * g++.dg/ext/label11.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/ext/label11.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/semantics.c
    trunk/gcc/testsuite/ChangeLog

------- Comment #6 From Jakub Jelinek 2009-01-08 00:28 -------
Fixed.

Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug