public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/52672] New: internal compiler error: in cxx_eval_indirect_ref, at cp/semantics.c:6766
@ 2012-03-22 16:50 meadori at codesourcery dot com
  2012-03-23  5:52 ` [Bug c++/52672] " meadori at codesourcery dot com
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: meadori at codesourcery dot com @ 2012-03-22 16:50 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52672

             Bug #: 52672
           Summary: internal compiler error: in cxx_eval_indirect_ref, at
                    cp/semantics.c:6766
    Classification: Unclassified
           Product: gcc
           Version: 4.6.4
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: meadori@codesourcery.com


Reproduced on a fresh 4.6 release branch build:

$ cat ~/etc/bugs/issue13031.cpp
typedef void (*func_t)(unsigned long);
typedef unsigned long * ul_ptr;

void
foo (unsigned long ul)
{
  ((func_t)((ul_ptr)(((ul_ptr)0x01000010)[14]))[0])(ul);
}
$ ./install/bin/arm-none-eabi-gcc --version
arm-none-eabi-gcc (GCC) 4.6.4 20120322 (prerelease)
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ ./install/bin/arm-none-eabi-gcc -std=gnu++0x  ~/etc/bugs/issue13031.cpp
/home/meadori/etc/bugs/issue13031.cpp: In function 'void foo(long unsigned
int)':
/home/meadori/etc/bugs/issue13031.cpp:7:50: internal compiler error: in
cxx_eval_indirect_ref, at cp/semantics.c:6766
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/52672] internal compiler error: in cxx_eval_indirect_ref, at cp/semantics.c:6766
  2012-03-22 16:50 [Bug c++/52672] New: internal compiler error: in cxx_eval_indirect_ref, at cp/semantics.c:6766 meadori at codesourcery dot com
@ 2012-03-23  5:52 ` meadori at codesourcery dot com
  2012-03-23 16:46 ` meadori at codesourcery dot com
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: meadori at codesourcery dot com @ 2012-03-23  5:52 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52672

Meador Inge <meadori at codesourcery dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|4.6.4                       |4.8.0

--- Comment #1 from Meador Inge <meadori at codesourcery dot com> 2012-03-23 02:29:46 UTC ---
Actually I found a smaller repro that also triggers in trunk:

typedef unsigned long * ul_ptr;

constexpr void * a = (void*) ((ul_ptr)(((ul_ptr)0x01000010)[14]))[0];

The problem happens when 'cxx_eval_indirect_ref' is presented with an
indirect reference expression that looks like:

<indirect_ref 0xf7dd6018
    type <integer_type 0xf7c524e0 long unsigned int public unsigned SI
        size <integer_cst 0xf7c3b5cc constant 32>
        unit size <integer_cst 0xf7c3b5e8 constant 4>
        align 32 symtab 0 alias set -1 canonical type 0xf7c524e0 precision 32
min <integer_cst 0xf7c3b984 0> max <integer_cst 0xf7c3b968 4294967295>
        pointer_to_this <pointer_type 0xf7dc9cc0>>

    arg 0 <nop_expr 0xf7dd6000
        type <pointer_type 0xf7dc9d20 ul_ptr type <integer_type 0xf7c524e0 long
unsigned int>
            unsigned SI size <integer_cst 0xf7c3b5cc 32> unit size <integer_cst
0xf7c3b5e8 4>
            align 32 symtab 0 alias set -1 canonical type 0xf7dc9cc0>

        arg 0 <indirect_ref 0xf7da3fc0 type <integer_type 0xf7c524e0 long
unsigned int>

            arg 0 <integer_cst 0xf7cabe54 constant 16777288>
            /home/meadori/etc/bugs/issue13031.cpp:3:63>
        /home/meadori/etc/bugs/issue13031.cpp:3:68>
    /home/meadori/etc/bugs/issue13031.cpp:3:68>

It calls into 'cxx_fold_indirect_ref' to fold the indirect reference operand
and
ends up stripping the NOP cast ending up with:

<indirect_ref 0xf7da3fc0
    type <integer_type 0xf7c524e0 long unsigned int public unsigned SI
        size <integer_cst 0xf7c3b5cc constant 32>
        unit size <integer_cst 0xf7c3b5e8 constant 4>
        align 32 symtab 0 alias set -1 canonical type 0xf7c524e0 precision 32
min <integer_cst 0xf7c3b984 0> max <integer_cst 0xf7c3b968 4294967295>
        pointer_to_this <pointer_type 0xf7dc9cc0>>

    arg 0 <integer_cst 0xf7cabe54 type <pointer_type 0xf7dc9d20 ul_ptr>
constant 16777288>

which, of course, fails the 'gcc_assert (POINTER_TYPE_P (subtype));' assert
in 'cxx_fold_indirect_ref'.

I would like to work out a patch for this one.  Any tips would be appreciated.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/52672] internal compiler error: in cxx_eval_indirect_ref, at cp/semantics.c:6766
  2012-03-22 16:50 [Bug c++/52672] New: internal compiler error: in cxx_eval_indirect_ref, at cp/semantics.c:6766 meadori at codesourcery dot com
  2012-03-23  5:52 ` [Bug c++/52672] " meadori at codesourcery dot com
@ 2012-03-23 16:46 ` meadori at codesourcery dot com
  2012-03-23 20:27 ` meadori at codesourcery dot com
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: meadori at codesourcery dot com @ 2012-03-23 16:46 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52672

--- Comment #2 from Meador Inge <meadori at codesourcery dot com> 2012-03-23 16:44:06 UTC ---
Even smaller repro:

constexpr unsigned long a = *((int*)(*((int*)0x0)));


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/52672] internal compiler error: in cxx_eval_indirect_ref, at cp/semantics.c:6766
  2012-03-22 16:50 [Bug c++/52672] New: internal compiler error: in cxx_eval_indirect_ref, at cp/semantics.c:6766 meadori at codesourcery dot com
  2012-03-23  5:52 ` [Bug c++/52672] " meadori at codesourcery dot com
  2012-03-23 16:46 ` meadori at codesourcery dot com
@ 2012-03-23 20:27 ` meadori at codesourcery dot com
  2012-03-27 18:18 ` jason at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: meadori at codesourcery dot com @ 2012-03-23 20:27 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52672

--- Comment #3 from Meador Inge <meadori at codesourcery dot com> 2012-03-23 20:21:06 UTC ---
Testing a patch now.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/52672] internal compiler error: in cxx_eval_indirect_ref, at cp/semantics.c:6766
  2012-03-22 16:50 [Bug c++/52672] New: internal compiler error: in cxx_eval_indirect_ref, at cp/semantics.c:6766 meadori at codesourcery dot com
                   ` (2 preceding siblings ...)
  2012-03-23 20:27 ` meadori at codesourcery dot com
@ 2012-03-27 18:18 ` jason at gcc dot gnu.org
  2012-03-30  6:30 ` jason at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jason at gcc dot gnu.org @ 2012-03-27 18:18 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52672

--- Comment #4 from Jason Merrill <jason at gcc dot gnu.org> 2012-03-27 18:08:20 UTC ---
Author: jason
Date: Tue Mar 27 18:08:13 2012
New Revision: 185890

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=185890
Log:
    PR c++/52672
    * gcc/cp/semantics.c (cxx_fold_indirect_ref): Don't attempt to fold
    stripped child trees that are not pointer types.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/constexpr-52672.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/semantics.c
    trunk/gcc/testsuite/ChangeLog


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/52672] internal compiler error: in cxx_eval_indirect_ref, at cp/semantics.c:6766
  2012-03-22 16:50 [Bug c++/52672] New: internal compiler error: in cxx_eval_indirect_ref, at cp/semantics.c:6766 meadori at codesourcery dot com
                   ` (3 preceding siblings ...)
  2012-03-27 18:18 ` jason at gcc dot gnu.org
@ 2012-03-30  6:30 ` jason at gcc dot gnu.org
  2012-04-13 23:07 ` meadori at codesourcery dot com
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jason at gcc dot gnu.org @ 2012-03-30  6:30 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52672

--- Comment #5 from Jason Merrill <jason at gcc dot gnu.org> 2012-03-30 03:48:18 UTC ---
Author: jason
Date: Fri Mar 30 03:48:12 2012
New Revision: 185989

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=185989
Log:
    PR c++/52672
    * gcc/cp/semantics.c (cxx_fold_indirect_ref): Don't attempt to fold
    stripped child trees that are not pointer types.

Added:
    branches/gcc-4_7-branch/gcc/testsuite/g++.dg/cpp0x/constexpr-52672.C
Modified:
    branches/gcc-4_7-branch/gcc/cp/ChangeLog
    branches/gcc-4_7-branch/gcc/cp/semantics.c
    branches/gcc-4_7-branch/gcc/testsuite/ChangeLog


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/52672] internal compiler error: in cxx_eval_indirect_ref, at cp/semantics.c:6766
  2012-03-22 16:50 [Bug c++/52672] New: internal compiler error: in cxx_eval_indirect_ref, at cp/semantics.c:6766 meadori at codesourcery dot com
                   ` (4 preceding siblings ...)
  2012-03-30  6:30 ` jason at gcc dot gnu.org
@ 2012-04-13 23:07 ` meadori at codesourcery dot com
  2012-05-07  2:50 ` paolo.carlini at oracle dot com
  2012-06-15 14:04 ` nightstrike at gmail dot com
  7 siblings, 0 replies; 9+ messages in thread
From: meadori at codesourcery dot com @ 2012-04-13 23:07 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52672

--- Comment #6 from Meador Inge <meadori at codesourcery dot com> 2012-04-13 23:07:09 UTC ---
Should the fix for this go into 4.6 as well?  If not, then I will close the
issue.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/52672] internal compiler error: in cxx_eval_indirect_ref, at cp/semantics.c:6766
  2012-03-22 16:50 [Bug c++/52672] New: internal compiler error: in cxx_eval_indirect_ref, at cp/semantics.c:6766 meadori at codesourcery dot com
                   ` (5 preceding siblings ...)
  2012-04-13 23:07 ` meadori at codesourcery dot com
@ 2012-05-07  2:50 ` paolo.carlini at oracle dot com
  2012-06-15 14:04 ` nightstrike at gmail dot com
  7 siblings, 0 replies; 9+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-05-07  2:50 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52672

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
      Known to work|                            |4.7.1, 4.8.0
         Resolution|                            |FIXED
   Target Milestone|---                         |4.7.1

--- Comment #7 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-05-07 00:19:25 UTC ---
Closing as fixed.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/52672] internal compiler error: in cxx_eval_indirect_ref, at cp/semantics.c:6766
  2012-03-22 16:50 [Bug c++/52672] New: internal compiler error: in cxx_eval_indirect_ref, at cp/semantics.c:6766 meadori at codesourcery dot com
                   ` (6 preceding siblings ...)
  2012-05-07  2:50 ` paolo.carlini at oracle dot com
@ 2012-06-15 14:04 ` nightstrike at gmail dot com
  7 siblings, 0 replies; 9+ messages in thread
From: nightstrike at gmail dot com @ 2012-06-15 14:04 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52672

nightstrike <nightstrike at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nightstrike at gmail dot
                   |                            |com

--- Comment #8 from nightstrike <nightstrike at gmail dot com> 2012-06-15 14:04:06 UTC ---
This fails on x86_64-w64-mingw32 with the following excess errors:


/opt/x/gcc/gcc/testsuite/g++.dg/cpp0x/constexpr-52672.C:7:54: warning: cast to
pointer from integer of different size [-Wint-to-pointer-cast]
/opt/x/gcc/gcc/testsuite/g++.dg/cpp0x/constexpr-52672.C:8:64: warning: cast to
pointer from integer of different size [-Wint-to-pointer-cast]
/opt/x/gcc/gcc/testsuite/g++.dg/cpp0x/constexpr-52672.C:8:65: warning: cast to
pointer from integer of different size [-Wint-to-pointer-cast]


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2012-06-15 14:04 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-22 16:50 [Bug c++/52672] New: internal compiler error: in cxx_eval_indirect_ref, at cp/semantics.c:6766 meadori at codesourcery dot com
2012-03-23  5:52 ` [Bug c++/52672] " meadori at codesourcery dot com
2012-03-23 16:46 ` meadori at codesourcery dot com
2012-03-23 20:27 ` meadori at codesourcery dot com
2012-03-27 18:18 ` jason at gcc dot gnu.org
2012-03-30  6:30 ` jason at gcc dot gnu.org
2012-04-13 23:07 ` meadori at codesourcery dot com
2012-05-07  2:50 ` paolo.carlini at oracle dot com
2012-06-15 14:04 ` nightstrike at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).