public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/65896] New: Erroneous uninitialized variable access error in constexpr function with temporary variables
@ 2015-04-26 16:32 david at doublewise dot net
2015-04-27 1:12 ` [Bug c++/65896] " david at doublewise dot net
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: david at doublewise dot net @ 2015-04-26 16:32 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65896
Bug ID: 65896
Summary: Erroneous uninitialized variable access error in
constexpr function with temporary variables
Product: gcc
Version: 5.1.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: david at doublewise dot net
Target Milestone: ---
file.cpp
==================================================
struct base{};
struct derived : base {
constexpr derived():
base{},
m_value(0) {
}
constexpr derived(derived & other):
base{},
m_value(other) {
}
constexpr explicit operator int() const {
return m_value;
}
int m_value;
};
constexpr int by_ref(derived && value) {
return (derived(value), 0);
}
constexpr int value = by_ref(derived{});
==================================================
c++ -std=c++11 -o /dev/null file.cpp -c
gcc 4.8.3 and 4.9.3 and clang 3.5.0 successfully compile this program. gcc
5.1.1 fails with:
file.cpp:22:29: in constexpr expansion of ‘by_ref(derived())’
file.cpp:22:39: in constexpr expansion of ‘derived((* & value))’
file.cpp:10:16: in constexpr expansion of ‘(& other)->derived::operator
int()’
file.cpp:22:39: error: accessing uninitialized member ‘derived::m_value’
constexpr int value = by_ref(derived{});
^
Changing to C++1y / C++14 does not change this.
>From gcc-bugs-return-484675-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sun Apr 26 17:39:37 2015
Return-Path: <gcc-bugs-return-484675-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 9995 invoked by alias); 26 Apr 2015 17:39:37 -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 9971 invoked by uid 48); 26 Apr 2015 17:39:33 -0000
From: "msebor at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/65892] gcc fails to implement N685 aliasing of union members
Date: Sun, 26 Apr 2015 17:39:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c
X-Bugzilla-Version: 5.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: msebor at gcc dot gnu.org
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Resolution:
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: bug_status resolution
Message-ID: <bug-65892-4-Mku0twnELx@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-65892-4@http.gcc.gnu.org/bugzilla/>
References: <bug-65892-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-04/txt/msg02227.txt.bz2
Content-length: 876
https://gcc.gnu.org/bugzilla/show_bug.cgi?ide892
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |UNCONFIRMED
Resolution|DUPLICATE |---
--- Comment #4 from Martin Sebor <msebor at gcc dot gnu.org> ---
Thanks for the pointer! I had looked for a related bug report but couldn't
find it.
There's an important difference between the test cases in pr14319 and the one
here that's easy to overlook. The rule only applies to structs defined in
unions, not those defined at file scope and only used to declare union members,
and to translation units in which the union definition is visible. I would
recommend closing pr14319 as NOTABUG. I have reopened this bug.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/65896] Erroneous uninitialized variable access error in constexpr function with temporary variables
2015-04-26 16:32 [Bug c++/65896] New: Erroneous uninitialized variable access error in constexpr function with temporary variables david at doublewise dot net
@ 2015-04-27 1:12 ` david at doublewise dot net
2015-04-27 8:39 ` [Bug c++/65896] [5/6 Regression] " redi at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: david at doublewise dot net @ 2015-04-27 1:12 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65896
David Stone <david at doublewise dot net> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |david at doublewise dot net
--- Comment #1 from David Stone <david at doublewise dot net> ---
I have simplified the test case further:
struct base {};
struct derived : base {
constexpr derived():
base{},
m_value(0) {
}
int m_value;
};
constexpr int by_ref(derived && value) {
return value.m_value;
}
constexpr int value = by_ref(derived{});
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/65896] [5/6 Regression] Erroneous uninitialized variable access error in constexpr function with temporary variables
2015-04-26 16:32 [Bug c++/65896] New: Erroneous uninitialized variable access error in constexpr function with temporary variables david at doublewise dot net
2015-04-27 1:12 ` [Bug c++/65896] " david at doublewise dot net
@ 2015-04-27 8:39 ` redi at gcc dot gnu.org
2015-04-28 21:27 ` jason at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2015-04-27 8:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65896
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |rejects-valid
Status|UNCONFIRMED |NEW
Last reconfirmed| |2015-04-27
Known to work| |4.8.3, 4.9.2
Summary|Erroneous uninitialized |[5/6 Regression] Erroneous
|variable access error in |uninitialized variable
|constexpr function with |access error in constexpr
|temporary variables |function with temporary
| |variables
Ever confirmed|0 |1
Known to fail| |5.1.0, 6.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/65896] [5/6 Regression] Erroneous uninitialized variable access error in constexpr function with temporary variables
2015-04-26 16:32 [Bug c++/65896] New: Erroneous uninitialized variable access error in constexpr function with temporary variables david at doublewise dot net
2015-04-27 1:12 ` [Bug c++/65896] " david at doublewise dot net
2015-04-27 8:39 ` [Bug c++/65896] [5/6 Regression] " redi at gcc dot gnu.org
@ 2015-04-28 21:27 ` jason at gcc dot gnu.org
2015-04-29 0:58 ` jason at gcc dot gnu.org
2015-04-29 0:58 ` jason at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: jason at gcc dot gnu.org @ 2015-04-28 21:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65896
--- Comment #2 from Jason Merrill <jason at gcc dot gnu.org> ---
Author: jason
Date: Tue Apr 28 21:27:17 2015
New Revision: 222549
URL: https://gcc.gnu.org/viewcvs?rev=222549&root=gcc&view=rev
Log:
PR c++/65896
* constexpr.c (cxx_eval_store_expression): Don't try to actually
store an empty class.
Added:
trunk/gcc/testsuite/g++.dg/cpp0x/constexpr-empty9.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/constexpr.c
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/65896] [5/6 Regression] Erroneous uninitialized variable access error in constexpr function with temporary variables
2015-04-26 16:32 [Bug c++/65896] New: Erroneous uninitialized variable access error in constexpr function with temporary variables david at doublewise dot net
` (2 preceding siblings ...)
2015-04-28 21:27 ` jason at gcc dot gnu.org
@ 2015-04-29 0:58 ` jason at gcc dot gnu.org
2015-04-29 0:58 ` jason at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: jason at gcc dot gnu.org @ 2015-04-29 0:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65896
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |jason at gcc dot gnu.org
Resolution|--- |FIXED
Assignee|unassigned at gcc dot gnu.org |jason at gcc dot gnu.org
Target Milestone|--- |5.2
--- Comment #4 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed for 5.2, 6
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/65896] [5/6 Regression] Erroneous uninitialized variable access error in constexpr function with temporary variables
2015-04-26 16:32 [Bug c++/65896] New: Erroneous uninitialized variable access error in constexpr function with temporary variables david at doublewise dot net
` (3 preceding siblings ...)
2015-04-29 0:58 ` jason at gcc dot gnu.org
@ 2015-04-29 0:58 ` jason at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: jason at gcc dot gnu.org @ 2015-04-29 0:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65896
--- Comment #3 from Jason Merrill <jason at gcc dot gnu.org> ---
Author: jason
Date: Wed Apr 29 00:57:50 2015
New Revision: 222557
URL: https://gcc.gnu.org/viewcvs?rev=222557&root=gcc&view=rev
Log:
PR c++/65896
* constexpr.c (cxx_eval_store_expression): Don't try to actually
store an empty class.
Added:
branches/gcc-5-branch/gcc/testsuite/g++.dg/cpp0x/constexpr-empty9.C
Modified:
branches/gcc-5-branch/gcc/cp/ChangeLog
branches/gcc-5-branch/gcc/cp/constexpr.c
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-04-29 0:58 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-26 16:32 [Bug c++/65896] New: Erroneous uninitialized variable access error in constexpr function with temporary variables david at doublewise dot net
2015-04-27 1:12 ` [Bug c++/65896] " david at doublewise dot net
2015-04-27 8:39 ` [Bug c++/65896] [5/6 Regression] " redi at gcc dot gnu.org
2015-04-28 21:27 ` jason at gcc dot gnu.org
2015-04-29 0:58 ` jason at gcc dot gnu.org
2015-04-29 0:58 ` 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).