public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/65509] New: [C++11] GCC rejects operator== with two distinct pointers as not constexpr
@ 2015-03-22  9:55 kariya_mitsuru at hotmail dot com
  2015-03-22 10:38 ` [Bug c++/65509] " daniel.kruegler at googlemail dot com
                   ` (16 more replies)
  0 siblings, 17 replies; 18+ messages in thread
From: kariya_mitsuru at hotmail dot com @ 2015-03-22  9:55 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65509

            Bug ID: 65509
           Summary: [C++11] GCC rejects operator== with two distinct
                    pointers as not constexpr
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: kariya_mitsuru at hotmail dot com

Created attachment 35091
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35091&action=edit
g++ -v

The sample code below should be compiled successfully but gcc 5.0 rejects it.

================= sample code =================
constexpr int i1 = 1;
constexpr int i2 = 2;

constexpr auto b = &i1 == &i2;

int main() {}
================= sample code =================
cf. http://melpon.org/wandbox/permlink/1Ae9Blr93vcU9qKQ


Note that gcc 4.9.2 accepts it.

cf. http://melpon.org/wandbox/permlink/72exRtJrkijS9D8u


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

* [Bug c++/65509] [C++11] GCC rejects operator== with two distinct pointers as not constexpr
  2015-03-22  9:55 [Bug c++/65509] New: [C++11] GCC rejects operator== with two distinct pointers as not constexpr kariya_mitsuru at hotmail dot com
@ 2015-03-22 10:38 ` daniel.kruegler at googlemail dot com
  2015-03-22 12:55 ` mpolacek at gcc dot gnu.org
                   ` (15 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2015-03-22 10:38 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65509

Daniel Krügler <daniel.kruegler at googlemail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |daniel.kruegler@googlemail.
                   |                            |com

--- Comment #1 from Daniel Krügler <daniel.kruegler at googlemail dot com> ---
I agree that this code should be accepted. Interestingly, the compiler accepts
the code when the constexpr specifier of both i1 and i2 is removed.
>From gcc-bugs-return-481100-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sun Mar 22 09:55:15 2015
Return-Path: <gcc-bugs-return-481100-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 43260 invoked by alias); 22 Mar 2015 09:55:14 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 43221 invoked by uid 48); 22 Mar 2015 09:55:09 -0000
From: "vries at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/65511] transform_to_exit_first_loop looses edge probabilities
Date: Sun, 22 Mar 2015 10:44:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: tree-optimization
X-Bugzilla-Version: 5.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: trivial
X-Bugzilla-Who: vries at gcc dot gnu.org
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-65511-4-lYpR9jJUBp@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-65511-4@http.gcc.gnu.org/bugzilla/>
References: <bug-65511-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-03/txt/msg02244.txt.bz2
Content-length: 962

https://gcc.gnu.org/bugzilla/show_bug.cgi?ide511

--- Comment #1 from vries at gcc dot gnu.org ---
tentative patch:
...
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 0f5e428..837dbbd 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -6175,6 +6175,7 @@ gimple_duplicate_sese_tail (edge entry ATTRIBUTE_UNUSED,
edge exit ATTRIBUTE_UNU
   gphi *phi;
   tree def;
   struct loop *target, *aloop, *cloop;
+  int exit_prob = exit->probability;

   gcc_assert (EDGE_COUNT (exit->src->succs) == 2);
   exits[0] = exit;
@@ -6266,6 +6267,8 @@ gimple_duplicate_sese_tail (edge entry ATTRIBUTE_UNUSED,
edge exit ATTRIBUTE_UNU
   sorig = single_succ_edge (switch_bb);
   sorig->flags = exits[1]->flags;
   snew = make_edge (switch_bb, nentry_bb, exits[0]->flags);
+  snew->probability = exit_prob;
+  sorig->probability = REG_BR_PROB_BASE - exit_prob;

   /* Register the new edge from SWITCH_BB in loop exit lists.  */
   rescan_loop_exit (snew, true, false);
...


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

* [Bug c++/65509] [C++11] GCC rejects operator== with two distinct pointers as not constexpr
  2015-03-22  9:55 [Bug c++/65509] New: [C++11] GCC rejects operator== with two distinct pointers as not constexpr kariya_mitsuru at hotmail dot com
  2015-03-22 10:38 ` [Bug c++/65509] " daniel.kruegler at googlemail dot com
@ 2015-03-22 12:55 ` mpolacek at gcc dot gnu.org
  2015-03-25  8:54 ` [Bug c++/65509] [5 Regression] " mpolacek at gcc dot gnu.org
                   ` (14 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2015-03-22 12:55 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65509

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-03-22
                 CC|                            |mpolacek at gcc dot gnu.org
     Ever confirmed|0                           |1


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

* [Bug c++/65509] [5 Regression] [C++11] GCC rejects operator== with two distinct pointers as not constexpr
  2015-03-22  9:55 [Bug c++/65509] New: [C++11] GCC rejects operator== with two distinct pointers as not constexpr kariya_mitsuru at hotmail dot com
  2015-03-22 10:38 ` [Bug c++/65509] " daniel.kruegler at googlemail dot com
  2015-03-22 12:55 ` mpolacek at gcc dot gnu.org
@ 2015-03-25  8:54 ` mpolacek at gcc dot gnu.org
  2015-03-25  9:04 ` jakub at gcc dot gnu.org
                   ` (13 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2015-03-25  8:54 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65509

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |5.0
            Summary|[C++11] GCC rejects         |[5 Regression] [C++11] GCC
                   |operator== with two         |rejects operator== with two
                   |distinct pointers as not    |distinct pointers as not
                   |constexpr                   |constexpr


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

* [Bug c++/65509] [5 Regression] [C++11] GCC rejects operator== with two distinct pointers as not constexpr
  2015-03-22  9:55 [Bug c++/65509] New: [C++11] GCC rejects operator== with two distinct pointers as not constexpr kariya_mitsuru at hotmail dot com
                   ` (2 preceding siblings ...)
  2015-03-25  8:54 ` [Bug c++/65509] [5 Regression] " mpolacek at gcc dot gnu.org
@ 2015-03-25  9:04 ` jakub at gcc dot gnu.org
  2015-03-25 10:07 ` jakub at gcc dot gnu.org
                   ` (12 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: jakub at gcc dot gnu.org @ 2015-03-25  9:04 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65509

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Yeah, it is r218462.


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

* [Bug c++/65509] [5 Regression] [C++11] GCC rejects operator== with two distinct pointers as not constexpr
  2015-03-22  9:55 [Bug c++/65509] New: [C++11] GCC rejects operator== with two distinct pointers as not constexpr kariya_mitsuru at hotmail dot com
                   ` (3 preceding siblings ...)
  2015-03-25  9:04 ` jakub at gcc dot gnu.org
@ 2015-03-25 10:07 ` jakub at gcc dot gnu.org
  2015-03-25 11:45 ` jakub at gcc dot gnu.org
                   ` (11 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: jakub at gcc dot gnu.org @ 2015-03-25 10:07 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65509

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hubicka at gcc dot gnu.org,
                   |                            |jason at gcc dot gnu.org

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The difference between when i1 and i2 are constexprs and when they are not is
that their cgraph nodes have definition = false if they are constexprs.
Dunno if that is intentional or not.


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

* [Bug c++/65509] [5 Regression] [C++11] GCC rejects operator== with two distinct pointers as not constexpr
  2015-03-22  9:55 [Bug c++/65509] New: [C++11] GCC rejects operator== with two distinct pointers as not constexpr kariya_mitsuru at hotmail dot com
                   ` (4 preceding siblings ...)
  2015-03-25 10:07 ` jakub at gcc dot gnu.org
@ 2015-03-25 11:45 ` jakub at gcc dot gnu.org
  2015-03-25 12:42 ` daniel.kruegler at googlemail dot com
                   ` (10 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: jakub at gcc dot gnu.org @ 2015-03-25 11:45 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65509

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
const int i1 = 1;
const int i2 = 2;
constexpr auto b = &i1 == &i2;
int main() {}

is now also rejected, when it used to be accepted.


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

* [Bug c++/65509] [5 Regression] [C++11] GCC rejects operator== with two distinct pointers as not constexpr
  2015-03-22  9:55 [Bug c++/65509] New: [C++11] GCC rejects operator== with two distinct pointers as not constexpr kariya_mitsuru at hotmail dot com
                   ` (5 preceding siblings ...)
  2015-03-25 11:45 ` jakub at gcc dot gnu.org
@ 2015-03-25 12:42 ` daniel.kruegler at googlemail dot com
  2015-03-25 14:44 ` mpolacek at gcc dot gnu.org
                   ` (9 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2015-03-25 12:42 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65509

--- Comment #6 from Daniel Krügler <daniel.kruegler at googlemail dot com> ---
(In reply to Jakub Jelinek from comment #5)
> const int i1 = 1;
> const int i2 = 2;
> constexpr auto b = &i1 == &i2;
> int main() {}
> 
> is now also rejected, when it used to be accepted.

Both behavioral changes look incorrect to me. The addresses of such global
objects are valid for equality comparison irrespective whether they are
constexpr or not, because == has no pre-condition:

"Two pointers compare equal if they are both null, both point to the same
function, or both represent the same address (3.9.2), otherwise they compare
unequal."

therefore we cannot fall into the exclusion bullet within 5.20 p2

"a relational (5.9) or equality (5.10) operator where the result is
unspecified;"
>From gcc-bugs-return-481587-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Wed Mar 25 11:46:15 2015
Return-Path: <gcc-bugs-return-481587-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 114637 invoked by alias); 25 Mar 2015 11:46:15 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 114604 invoked by uid 48); 25 Mar 2015 11:46:12 -0000
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug debug/65549] [5 Regression] crash in htab_hash_string with -flto
Date: Wed, 25 Mar 2015 12:48:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: debug
X-Bugzilla-Version: 5.0
X-Bugzilla-Keywords: lto
X-Bugzilla-Severity: normal
X-Bugzilla-Who: rguenth at gcc dot gnu.org
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 5.0
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: target_milestone
Message-ID: <bug-65549-4-zwilpgnW1I@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-65549-4@http.gcc.gnu.org/bugzilla/>
References: <bug-65549-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-03/txt/msg02731.txt.bz2
Content-length: 292

https://gcc.gnu.org/bugzilla/show_bug.cgi?ide549

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |5.0


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

* [Bug c++/65509] [5 Regression] [C++11] GCC rejects operator== with two distinct pointers as not constexpr
  2015-03-22  9:55 [Bug c++/65509] New: [C++11] GCC rejects operator== with two distinct pointers as not constexpr kariya_mitsuru at hotmail dot com
                   ` (6 preceding siblings ...)
  2015-03-25 12:42 ` daniel.kruegler at googlemail dot com
@ 2015-03-25 14:44 ` mpolacek at gcc dot gnu.org
  2015-03-25 15:07 ` mpolacek at gcc dot gnu.org
                   ` (8 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2015-03-25 14:44 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65509

--- Comment #7 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #4)
> The difference between when i1 and i2 are constexprs and when they are not
> is that their cgraph nodes have definition = false if they are constexprs.
> Dunno if that is intentional or not.

True, they don't have definitions because we're trying to evaluate the
constexpr comparison in cxx_eval_binary_expression before finalize_decl could
create the definitions for i1 and i2.


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

* [Bug c++/65509] [5 Regression] [C++11] GCC rejects operator== with two distinct pointers as not constexpr
  2015-03-22  9:55 [Bug c++/65509] New: [C++11] GCC rejects operator== with two distinct pointers as not constexpr kariya_mitsuru at hotmail dot com
                   ` (7 preceding siblings ...)
  2015-03-25 14:44 ` mpolacek at gcc dot gnu.org
@ 2015-03-25 15:07 ` mpolacek at gcc dot gnu.org
  2015-03-25 15:35 ` jakub at gcc dot gnu.org
                   ` (7 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2015-03-25 15:07 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65509

--- Comment #8 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
The following (untested) should work:

--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -6113,6 +6113,7 @@ make_rtl_for_nonlocal_decl (tree decl, tree init, const
char* asmspec)
      not emitted into the object file unnecessarily.  */
   filename = LOCATION_FILE (input_location);
   if (!DECL_VIRTUAL_P (decl)
+      && !DECL_DECLARED_CONSTEXPR_P (decl)
       && TREE_READONLY (decl)
       && DECL_INITIAL (decl) != NULL_TREE
       && DECL_INITIAL (decl) != error_mark_node

My reasoning is that we shouldn't defer assembling the variable if it might be
needed in the constexpr context.


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

* [Bug c++/65509] [5 Regression] [C++11] GCC rejects operator== with two distinct pointers as not constexpr
  2015-03-22  9:55 [Bug c++/65509] New: [C++11] GCC rejects operator== with two distinct pointers as not constexpr kariya_mitsuru at hotmail dot com
                   ` (8 preceding siblings ...)
  2015-03-25 15:07 ` mpolacek at gcc dot gnu.org
@ 2015-03-25 15:35 ` jakub at gcc dot gnu.org
  2015-03-25 15:39 ` mpolacek at gcc dot gnu.org
                   ` (6 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: jakub at gcc dot gnu.org @ 2015-03-25 15:35 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65509

--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Marek Polacek from comment #8)
> The following (untested) should work:
> 
> --- a/gcc/cp/decl.c
> +++ b/gcc/cp/decl.c
> @@ -6113,6 +6113,7 @@ make_rtl_for_nonlocal_decl (tree decl, tree init,
> const char* asmspec)
>       not emitted into the object file unnecessarily.  */
>    filename = LOCATION_FILE (input_location);
>    if (!DECL_VIRTUAL_P (decl)
> +      && !DECL_DECLARED_CONSTEXPR_P (decl)
>        && TREE_READONLY (decl)
>        && DECL_INITIAL (decl) != NULL_TREE
>        && DECL_INITIAL (decl) != error_mark_node
> 
> My reasoning is that we shouldn't defer assembling the variable if it might
> be needed in the constexpr context.

But in the #c5 testcase it isn't DECL_DECLARED_CONSTEXPR_P, is it?


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

* [Bug c++/65509] [5 Regression] [C++11] GCC rejects operator== with two distinct pointers as not constexpr
  2015-03-22  9:55 [Bug c++/65509] New: [C++11] GCC rejects operator== with two distinct pointers as not constexpr kariya_mitsuru at hotmail dot com
                   ` (9 preceding siblings ...)
  2015-03-25 15:35 ` jakub at gcc dot gnu.org
@ 2015-03-25 15:39 ` mpolacek at gcc dot gnu.org
  2015-03-27 16:37 ` jason at gcc dot gnu.org
                   ` (5 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2015-03-25 15:39 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65509

--- Comment #10 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #9)
> But in the #c5 testcase it isn't DECL_DECLARED_CONSTEXPR_P, is it?

True :(.


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

* [Bug c++/65509] [5 Regression] [C++11] GCC rejects operator== with two distinct pointers as not constexpr
  2015-03-22  9:55 [Bug c++/65509] New: [C++11] GCC rejects operator== with two distinct pointers as not constexpr kariya_mitsuru at hotmail dot com
                   ` (10 preceding siblings ...)
  2015-03-25 15:39 ` mpolacek at gcc dot gnu.org
@ 2015-03-27 16:37 ` jason at gcc dot gnu.org
  2015-03-27 16:54 ` jason at gcc dot gnu.org
                   ` (4 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: jason at gcc dot gnu.org @ 2015-03-27 16:37 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65509

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |jason at gcc dot gnu.org

--- Comment #11 from Jason Merrill <jason at gcc dot gnu.org> ---
OK, the issue seems to be that make_rtl_for_nonlocal_decl in the front end is
trying to defer calling rest_of_decl_compilation for static constant variables.
 Now that we have cgraph, the front end shouldn't be trying to play these types
of games.


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

* [Bug c++/65509] [5 Regression] [C++11] GCC rejects operator== with two distinct pointers as not constexpr
  2015-03-22  9:55 [Bug c++/65509] New: [C++11] GCC rejects operator== with two distinct pointers as not constexpr kariya_mitsuru at hotmail dot com
                   ` (11 preceding siblings ...)
  2015-03-27 16:37 ` jason at gcc dot gnu.org
@ 2015-03-27 16:54 ` jason at gcc dot gnu.org
  2015-03-27 16:54 ` jason at gcc dot gnu.org
                   ` (3 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: jason at gcc dot gnu.org @ 2015-03-27 16:54 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65509

--- Comment #12 from Jason Merrill <jason at gcc dot gnu.org> ---
Author: jason
Date: Fri Mar 27 16:36:32 2015
New Revision: 221737

URL: https://gcc.gnu.org/viewcvs?rev=221737&root=gcc&view=rev
Log:
    PR c++/65509
    * decl.c (make_rtl_for_nonlocal_decl): Don't defer static
    constants.

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


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

* [Bug c++/65509] [5 Regression] [C++11] GCC rejects operator== with two distinct pointers as not constexpr
  2015-03-22  9:55 [Bug c++/65509] New: [C++11] GCC rejects operator== with two distinct pointers as not constexpr kariya_mitsuru at hotmail dot com
                   ` (12 preceding siblings ...)
  2015-03-27 16:54 ` jason at gcc dot gnu.org
@ 2015-03-27 16:54 ` jason at gcc dot gnu.org
  2015-03-28 18:24 ` kariya_mitsuru at hotmail dot com
                   ` (2 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: jason at gcc dot gnu.org @ 2015-03-27 16:54 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65509

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #13 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed.


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

* [Bug c++/65509] [5 Regression] [C++11] GCC rejects operator== with two distinct pointers as not constexpr
  2015-03-22  9:55 [Bug c++/65509] New: [C++11] GCC rejects operator== with two distinct pointers as not constexpr kariya_mitsuru at hotmail dot com
                   ` (13 preceding siblings ...)
  2015-03-27 16:54 ` jason at gcc dot gnu.org
@ 2015-03-28 18:24 ` kariya_mitsuru at hotmail dot com
  2015-03-28 18:31 ` kariya_mitsuru at hotmail dot com
  2015-03-29 19:29 ` jason at gcc dot gnu.org
  16 siblings, 0 replies; 18+ messages in thread
From: kariya_mitsuru at hotmail dot com @ 2015-03-28 18:24 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65509

--- Comment #14 from Mitsuru Kariya <kariya_mitsuru at hotmail dot com> ---
The rev.221737 seems to be able to compile the sample code above, but cannot
compile another sample code like below.

================= sample code =================
constexpr char s1[] = "s1";
constexpr char s2[] = "s2";

constexpr auto eq = (s1 + 0) == (s2 + 1);

int main() {}
================= sample code =================
================ error message ================
compare2.cpp:4:30: error: '(((const char*)(& s1)) == (((const char*)(& s2)) +
1u))' is not a constant expression
 constexpr auto eq = (s1 + 0) == (s2 + 1);
================ error message ================

Although the first sample causes compilation error only in 5.0.0, the second
sample causes compilation error in 4.9.2 too.

cf. http://melpon.org/wandbox/permlink/KhcREuNqGofbZvqw


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

* [Bug c++/65509] [5 Regression] [C++11] GCC rejects operator== with two distinct pointers as not constexpr
  2015-03-22  9:55 [Bug c++/65509] New: [C++11] GCC rejects operator== with two distinct pointers as not constexpr kariya_mitsuru at hotmail dot com
                   ` (14 preceding siblings ...)
  2015-03-28 18:24 ` kariya_mitsuru at hotmail dot com
@ 2015-03-28 18:31 ` kariya_mitsuru at hotmail dot com
  2015-03-29 19:29 ` jason at gcc dot gnu.org
  16 siblings, 0 replies; 18+ messages in thread
From: kariya_mitsuru at hotmail dot com @ 2015-03-28 18:31 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65509

Mitsuru Kariya <kariya_mitsuru at hotmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |---

--- Comment #15 from Mitsuru Kariya <kariya_mitsuru at hotmail dot com> ---
I found another sample like below.

================= sample code =================
constexpr char s[] = "s";

constexpr auto eq = (&s[0] + 0) == (&s[0] + 1);

int main() {}
================= sample code =================
================ error message ================
compare3.cpp:3:33: error: '((& s[0]) == ((& s[0]) + 1u))' is not a constant
expression
 constexpr auto eq = (&s[0] + 0) == (&s[0] + 1);
================ error message ================

Note that gcc 4.9.2 accepts it.

cf. http://melpon.org/wandbox/permlink/RybrdNbUdtMi39wX


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

* [Bug c++/65509] [5 Regression] [C++11] GCC rejects operator== with two distinct pointers as not constexpr
  2015-03-22  9:55 [Bug c++/65509] New: [C++11] GCC rejects operator== with two distinct pointers as not constexpr kariya_mitsuru at hotmail dot com
                   ` (15 preceding siblings ...)
  2015-03-28 18:31 ` kariya_mitsuru at hotmail dot com
@ 2015-03-29 19:29 ` jason at gcc dot gnu.org
  16 siblings, 0 replies; 18+ messages in thread
From: jason at gcc dot gnu.org @ 2015-03-29 19:29 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65509

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #16 from Jason Merrill <jason at gcc dot gnu.org> ---
I think these additional testcases should go on bug 65398, not this one; these
cases also deal with the address of an array element.


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

end of thread, other threads:[~2015-03-29 17:42 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-22  9:55 [Bug c++/65509] New: [C++11] GCC rejects operator== with two distinct pointers as not constexpr kariya_mitsuru at hotmail dot com
2015-03-22 10:38 ` [Bug c++/65509] " daniel.kruegler at googlemail dot com
2015-03-22 12:55 ` mpolacek at gcc dot gnu.org
2015-03-25  8:54 ` [Bug c++/65509] [5 Regression] " mpolacek at gcc dot gnu.org
2015-03-25  9:04 ` jakub at gcc dot gnu.org
2015-03-25 10:07 ` jakub at gcc dot gnu.org
2015-03-25 11:45 ` jakub at gcc dot gnu.org
2015-03-25 12:42 ` daniel.kruegler at googlemail dot com
2015-03-25 14:44 ` mpolacek at gcc dot gnu.org
2015-03-25 15:07 ` mpolacek at gcc dot gnu.org
2015-03-25 15:35 ` jakub at gcc dot gnu.org
2015-03-25 15:39 ` mpolacek at gcc dot gnu.org
2015-03-27 16:37 ` jason at gcc dot gnu.org
2015-03-27 16:54 ` jason at gcc dot gnu.org
2015-03-27 16:54 ` jason at gcc dot gnu.org
2015-03-28 18:24 ` kariya_mitsuru at hotmail dot com
2015-03-28 18:31 ` kariya_mitsuru at hotmail dot com
2015-03-29 19:29 ` 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).