public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/51554] New: ICE in cp/semantics.c:cxx_eval_indirect_ref with -Wall
@ 2011-12-14 20:11 dnovillo at gcc dot gnu.org
  2011-12-14 22:27 ` [Bug c++/51554] " jason at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: dnovillo at gcc dot gnu.org @ 2011-12-14 20:11 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 51554
           Summary: ICE in cp/semantics.c:cxx_eval_indirect_ref with -Wall
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: dnovillo@gcc.gnu.org
                CC: jason@redhat.com, singhai@gcc.gnu.org


In:

static tree
cxx_eval_indirect_ref (const constexpr_call *call, tree t,
                       bool allow_non_constant, bool addr,
                       bool *non_constant_p)
{
[ ... ]
  if (r)
    r = cxx_eval_constant_expression (call, r, allow_non_constant,
                                      addr, non_constant_p);
  else
    {
      tree sub = op0;
      STRIP_NOPS (sub);
      if (TREE_CODE (sub) == ADDR_EXPR
          || TREE_CODE (sub) == POINTER_PLUS_EXPR)
        {
==>          gcc_assert (!same_type_ignoring_top_level_qualifiers_p
==>                      (TREE_TYPE (TREE_TYPE (sub)), TREE_TYPE (t)));
          /* DR 1188 says we don't have to deal with this.  */
          if (!allow_non_constant)

at the point of the failure, we have:

t: *((const uint8 *) &XX[0] + 1);
sub: (const uint8 *) &XX[0] + 1;

and (naturally) TREE_TYPE(t) is the same as TREE_TYPE(TREE_TYPE(sub)), so the
assertion fails trivially. 

The values for T and SUB seem to come unmodified all the way up from
process_init_constructor_array.  The original source code where this is coming
from is:

const uint8 F::V[] = {
  ...
  *(reinterpret_cast<const uint8*>(&XX[0]) + 1),
  ...
};

This code seems to be enabled only with -Wall, the following reproducer only
fails if compiled with -Wall:

$ cat a.cc
typedef unsigned char uint8;
typedef unsigned int uint32;

const uint32 XX[] = { 1, 3, 7 };

const uint8 V[] = {
  *(reinterpret_cast<const uint8*>(&XX[0]) + 0),
  *(reinterpret_cast<const uint8*>(&XX[0]) + 1),
  *(reinterpret_cast<const uint8*>(&XX[0]) + 2),
  *(reinterpret_cast<const uint8*>(&XX[0]) + 3),
  *(reinterpret_cast<const uint8*>(&XX[1]) + 0),
  *(reinterpret_cast<const uint8*>(&XX[1]) + 1),
  *(reinterpret_cast<const uint8*>(&XX[1]) + 2),
  *(reinterpret_cast<const uint8*>(&XX[1]) + 3),
};

$ g++ -Wall -c a.cc
a.cc:15:1: internal compiler error: in cxx_eval_indirect_ref, at
cp/semantics.c:7321
Please submit a full bug report,
with preprocessed source if appropriate.


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

* [Bug c++/51554] ICE in cp/semantics.c:cxx_eval_indirect_ref with -Wall
  2011-12-14 20:11 [Bug c++/51554] New: ICE in cp/semantics.c:cxx_eval_indirect_ref with -Wall dnovillo at gcc dot gnu.org
@ 2011-12-14 22:27 ` jason at gcc dot gnu.org
  2011-12-14 22:33 ` dnovillo at google dot com
  2011-12-14 22:57 ` jason at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: jason at gcc dot gnu.org @ 2011-12-14 22:27 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jason Merrill <jason at gcc dot gnu.org> 2011-12-14 22:26:27 UTC ---
Author: jason
Date: Wed Dec 14 22:26:24 2011
New Revision: 182346

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=182346
Log:
    PR c++/51554
    * semantics.c (cxx_eval_indirect_ref): Fix sanity check.

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


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

* [Bug c++/51554] ICE in cp/semantics.c:cxx_eval_indirect_ref with -Wall
  2011-12-14 20:11 [Bug c++/51554] New: ICE in cp/semantics.c:cxx_eval_indirect_ref with -Wall dnovillo at gcc dot gnu.org
  2011-12-14 22:27 ` [Bug c++/51554] " jason at gcc dot gnu.org
@ 2011-12-14 22:33 ` dnovillo at google dot com
  2011-12-14 22:57 ` jason at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: dnovillo at google dot com @ 2011-12-14 22:33 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from dnovillo at google dot com <dnovillo at google dot com> 2011-12-14 22:32:33 UTC ---
Wow, that was quick, thanks!


Diego.

On Wed, Dec 14, 2011 at 17:26, jason at gcc dot gnu.org
<gcc-bugzilla@gcc.gnu.org> wrote:
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51554
>
> --- Comment #1 from Jason Merrill <jason at gcc dot gnu.org> 2011-12-14 22:26:27 UTC ---
> Author: jason
> Date: Wed Dec 14 22:26:24 2011
> New Revision: 182346
>
> URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=182346
> Log:
>    PR c++/51554
>    * semantics.c (cxx_eval_indirect_ref): Fix sanity check.
>
> Added:
>    trunk/gcc/testsuite/g++.dg/init/constant1.C
> Modified:
>    trunk/gcc/cp/ChangeLog
>    trunk/gcc/cp/semantics.c
>    trunk/gcc/testsuite/ChangeLog
>
> --
> Configure bugmail: http://gcc.gnu.org/bugzilla/userprefs.cgi?tab=email
> ------- You are receiving this mail because: -------
> You reported the bug.


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

* [Bug c++/51554] ICE in cp/semantics.c:cxx_eval_indirect_ref with -Wall
  2011-12-14 20:11 [Bug c++/51554] New: ICE in cp/semantics.c:cxx_eval_indirect_ref with -Wall dnovillo at gcc dot gnu.org
  2011-12-14 22:27 ` [Bug c++/51554] " jason at gcc dot gnu.org
  2011-12-14 22:33 ` dnovillo at google dot com
@ 2011-12-14 22:57 ` jason at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: jason at gcc dot gnu.org @ 2011-12-14 22:57 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |jason at gcc dot gnu.org
         Resolution|                            |FIXED
   Target Milestone|---                         |4.7.0

--- Comment #3 from Jason Merrill <jason at gcc dot gnu.org> 2011-12-14 22:55:50 UTC ---
Fixed.


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

end of thread, other threads:[~2011-12-14 22:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-14 20:11 [Bug c++/51554] New: ICE in cp/semantics.c:cxx_eval_indirect_ref with -Wall dnovillo at gcc dot gnu.org
2011-12-14 22:27 ` [Bug c++/51554] " jason at gcc dot gnu.org
2011-12-14 22:33 ` dnovillo at google dot com
2011-12-14 22:57 ` jason at gcc dot gnu.org

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).