public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/60771] New: rejects-valid: static constexpr const reference initialization
@ 2014-04-06 1:04 filip.roseen at gmail dot com
2014-06-06 9:33 ` [Bug c++/60771] rejects-valid: static in-class " paolo.carlini at oracle dot com
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: filip.roseen at gmail dot com @ 2014-04-06 1:04 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60771
Bug ID: 60771
Summary: rejects-valid: static constexpr const reference
initialization
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: filip.roseen at gmail dot com
Created attachment 32550
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32550&action=edit
testcase.cpp
struct A {
static constexpr int const& ref = 5;
};
int main () { }
------------------------------------------------------------------
testcase.cpp:2:37: error: non-constant in-class initialization invalid for
static member ‘A::ref’
static constexpr int const& ref = 5;
^
testcase.cpp:2:37: error: (an out of class initialization is required)
testcase.cpp:2:37: error: ‘A::ref’ cannot be initialized by a non-constant
expression when being declared
------------------------------------------------------------------
The snippet should be accepted, `int const&` is a literal-type and `5` sure is
a constant expression suitable for initializing `ref` in the written context.
[ Note: `gcc` correctly accepts `static constexpr int const& ref = 5;` if it
appears outside of a class definition. ]
[ Note: `clang` shows the correct behavior. ]
------------------------------------------------------------------
[basic.start.init]p2:
> Variables with static storage duration (3.7.1) or thread storage
> duration (3.7.2) shall be zero-initialized (8.5) before any other
> initialization takes place. A constant initializer for an object o is
> an expression that is a constant expression, except that it may also
> invoke constexpr constructors for o and its subobjects even if those
> objects are of non-literal class types [ Note: such a class may have a
> non-trivial destructor — end note ].
>
> Constant initialization is performed:
>
> — if each full-expression (including implicit conversions) that
> appears in the initializer of a reference with static or
> thread storage duration is a constant expression (5.19) and
> the reference is bound to an lvalue designating an object
> with static storage duration or to a temporary (see 12.2);
>
> </snip>
>From gcc-bugs-return-448381-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sun Apr 06 04:40:09 2014
Return-Path: <gcc-bugs-return-448381-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 16247 invoked by alias); 6 Apr 2014 04:40:06 -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 16199 invoked by uid 48); 6 Apr 2014 04:40:00 -0000
From: "andi-gcc at firstfloor dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/60469] simple cilk plus program ICEs
Date: Sun, 06 Apr 2014 04:40:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: middle-end
X-Bugzilla-Version: unknown
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: andi-gcc at firstfloor dot 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-60469-4-ChVD1UKKKm@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-60469-4@http.gcc.gnu.org/bugzilla/>
References: <bug-60469-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: 2014-04/txt/msg00401.txt.bz2
Content-length: 2092
http://gcc.gnu.org/bugzilla/show_bug.cgi?id`469
--- Comment #1 from Andi Kleen <andi-gcc at firstfloor dot org> ---
I investigated this a bit.
The problem is in get_chain_decl() in the nested function lowering because Cilk
creates nested functions.
info->outer is NULL
created_nesting_tree does this
for (cgn = cgn->nested; cgn ; cgn = cgn->next_nested)
{
struct nesting_info *sub = create_nesting_tree (cgn);
sub->outer = info;
sub->next = info->inner;
info->inner = sub;
}
So it would only set ->outer for any inner functions and it is expected to be
NULL on the outer most nesting level
$6 = {outer = 0x0, inner = 0x329b590, next = 0x0, field_map = 0x329c780,
var_map = 0x329dc70, mem_refs = 0x329e850, suppress_expansion = 0x32f8d20,
context = <function_decl 0x7fe4297b7e00 main>, new_local_var_chain = <tree
0x0>, debug_var_chain = <tree 0x0>, frame_type = <tree 0x0>, frame_decl = <tree
0x0>,
chain_field = <tree 0x0>, chain_decl = <tree 0x0>, nl_goto_field = <tree
0x0>, any_parm_remapped = false, any_tramp_created = false, static_chain_added
= 0 '\000'}
So this whole code is invoked on the most outer most context, which it cannot
deal with
This seems to be related to the decl_function_context farther up the callstack:
static tree
convert_nonlocal_reference_op (tree *tp, int *walk_subtrees, void *data)
{
struct walk_stmt_info *wi = (struct walk_stmt_info *) data;
struct nesting_info *const info = (struct nesting_info *) wi->info;
tree t = *tp;
*walk_subtrees = 0;
switch (TREE_CODE (t))
{
case VAR_DECL:
/* Non-automatic variables are never processed. */
if (TREE_STATIC (t) || DECL_EXTERNAL (t))
break;
/* FALLTHRU */
case PARM_DECL:
if (decl_function_context (t) != info->context)
(gdb) p t->decl_minimal.context
$11 = <tree 0x0>
(gdb) p info->context
$12 = <function_decl 0x7fe4297b7e00 main>
This means the VAR_DECL doesn't have the correct context
Looking at c-common/cilk.c it seems to copy VAR_DECLs.
So it somehow doesn't set up the context correctly?
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/60771] rejects-valid: static in-class constexpr const reference initialization
2014-04-06 1:04 [Bug c++/60771] New: rejects-valid: static constexpr const reference initialization filip.roseen at gmail dot com
@ 2014-06-06 9:33 ` paolo.carlini at oracle dot com
2014-11-18 10:58 ` [Bug c++/60771] " paolo.carlini at oracle dot com
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: paolo.carlini at oracle dot com @ 2014-06-06 9:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60771
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2014-06-06
Blocks| |55004
Ever confirmed|0 |1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/60771] static in-class constexpr const reference initialization
2014-04-06 1:04 [Bug c++/60771] New: rejects-valid: static constexpr const reference initialization filip.roseen at gmail dot com
2014-06-06 9:33 ` [Bug c++/60771] rejects-valid: static in-class " paolo.carlini at oracle dot com
@ 2014-11-18 10:58 ` paolo.carlini at oracle dot com
2014-11-18 11:26 ` paolo at gcc dot gnu.org
2014-11-18 11:27 ` paolo.carlini at oracle dot com
3 siblings, 0 replies; 5+ messages in thread
From: paolo.carlini at oracle dot com @ 2014-11-18 10:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60771
--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> ---
This is fixed by the commit which fixed c++/50473 (r217672). I'm adding the
testcase and closing the bug.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/60771] static in-class constexpr const reference initialization
2014-04-06 1:04 [Bug c++/60771] New: rejects-valid: static constexpr const reference initialization filip.roseen at gmail dot com
2014-06-06 9:33 ` [Bug c++/60771] rejects-valid: static in-class " paolo.carlini at oracle dot com
2014-11-18 10:58 ` [Bug c++/60771] " paolo.carlini at oracle dot com
@ 2014-11-18 11:26 ` paolo at gcc dot gnu.org
2014-11-18 11:27 ` paolo.carlini at oracle dot com
3 siblings, 0 replies; 5+ messages in thread
From: paolo at gcc dot gnu.org @ 2014-11-18 11:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60771
--- Comment #2 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> ---
Author: paolo
Date: Tue Nov 18 11:25:47 2014
New Revision: 217708
URL: https://gcc.gnu.org/viewcvs?rev=217708&root=gcc&view=rev
Log:
2014-11-18 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/60771
* g++.dg/cpp0x/constexpr-ref6.C: New.
Added:
trunk/gcc/testsuite/g++.dg/cpp0x/constexpr-ref6.C
Modified:
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/60771] static in-class constexpr const reference initialization
2014-04-06 1:04 [Bug c++/60771] New: rejects-valid: static constexpr const reference initialization filip.roseen at gmail dot com
` (2 preceding siblings ...)
2014-11-18 11:26 ` paolo at gcc dot gnu.org
@ 2014-11-18 11:27 ` paolo.carlini at oracle dot com
3 siblings, 0 replies; 5+ messages in thread
From: paolo.carlini at oracle dot com @ 2014-11-18 11:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60771
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
Target Milestone|--- |5.0
--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Done.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-11-18 11:27 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-06 1:04 [Bug c++/60771] New: rejects-valid: static constexpr const reference initialization filip.roseen at gmail dot com
2014-06-06 9:33 ` [Bug c++/60771] rejects-valid: static in-class " paolo.carlini at oracle dot com
2014-11-18 10:58 ` [Bug c++/60771] " paolo.carlini at oracle dot com
2014-11-18 11:26 ` paolo at gcc dot gnu.org
2014-11-18 11:27 ` paolo.carlini at oracle 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).