public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/57820] New: Can't initialize a constexpr object with inline initialization
@ 2013-07-04 9:45 liweifriends at gmail dot com
2013-07-04 9:57 ` [Bug c++/57820] " redi at gcc dot gnu.org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: liweifriends at gmail dot com @ 2013-07-04 9:45 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57820
Bug ID: 57820
Summary: Can't initialize a constexpr object with inline
initialization
Product: gcc
Version: 4.8.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: liweifriends at gmail dot com
the source code:
struct C
{
int a = 2;
int b = a + 1;
};
C c; //OK
constexpr C d; //error
int main()
{
}
Why I can't initialize d?
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/57820] Can't initialize a constexpr object with inline initialization
2013-07-04 9:45 [Bug c++/57820] New: Can't initialize a constexpr object with inline initialization liweifriends at gmail dot com
@ 2013-07-04 9:57 ` redi at gcc dot gnu.org
2013-07-04 17:46 ` harald at gigawatt dot nl
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2013-07-04 9:57 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57820
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2013-07-04
Ever confirmed|0 |1
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I think it's invalid unless you provide an initializer or the class has a
default constructor e.g.
constexpr C d = {};
G++ still rejects that though, with a very unhelpful diagnostic:
t.cc:8:18: error: ‘constexpr C::C()’ called in a constant expression
constexpr C d = {}; //error
^
t.cc:1:8: note: ‘constexpr C::C()’ is not usable as a constexpr function
because:
struct C
^
>From gcc-bugs-return-425736-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Jul 04 10:00:17 2013
Return-Path: <gcc-bugs-return-425736-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 12998 invoked by alias); 4 Jul 2013 10:00:17 -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 12902 invoked by uid 48); 4 Jul 2013 10:00:11 -0000
From: "burnus at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/47007] Values from namelist file should not depend on locale settings
Date: Thu, 04 Jul 2013 10:00:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: fortran
X-Bugzilla-Version: 4.4.5
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: burnus at gcc dot gnu.org
X-Bugzilla-Status: ASSIGNED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: jvdelisle at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: cc
Message-ID: <bug-47007-4-ij4FM8XRAQ@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-47007-4@http.gcc.gnu.org/bugzilla/>
References: <bug-47007-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: 2013-07/txt/msg00243.txt.bz2
Content-length: 1284
http://gcc.gnu.org/bugzilla/show_bug.cgi?idG007
Tobias Burnus <burnus at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |burnus at gcc dot gnu.org
--- Comment #18 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Given that we already have some special handling for DECIMAL="comma", I wonder
whether one couldn't simply undo the setting by used, e.g.,
const char *decimal;
size_t decimal_len;
#if defined USE_LOCALECONV && !defined USE_NL_LANGINFO
const struct lconv *lc = localeconv ();
#endif
#ifdef USE_NL_LANGINFO
decimal = nl_langinfo (DECIMAL_POINT);
decimal_len = strlen (decimal);
assert (decimal_len > 0);
#elif defined USE_LOCALECONV
decimal = lc->decimal_point;
if (decimal == NULL || *decimal == '\0')
decimal = ".";
decimal_len = strlen (decimal);
#else
decimal = ".";
decimal_len = 1;
#endif
And then simply replace for decimal_len the existing ("." or ",") decimal
character from the read string/file by the one obtained for the local - before
sending it to strtof/strtod/strtold/strtoflt128.
(Note: decimal_len is probably nearly always == 1, but it might be different.)
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/57820] Can't initialize a constexpr object with inline initialization
2013-07-04 9:45 [Bug c++/57820] New: Can't initialize a constexpr object with inline initialization liweifriends at gmail dot com
2013-07-04 9:57 ` [Bug c++/57820] " redi at gcc dot gnu.org
@ 2013-07-04 17:46 ` harald at gigawatt dot nl
2014-11-03 10:40 ` paolo.carlini at oracle dot com
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: harald at gigawatt dot nl @ 2013-07-04 17:46 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57820
Harald van Dijk <harald at gigawatt dot nl> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |harald at gigawatt dot nl
--- Comment #2 from Harald van Dijk <harald at gigawatt dot nl> ---
Adding an user-defined constexpr C() {} makes it fail more clearly:
struct C
{
int a = 2;
int b = a + 1;
constexpr C() {}
};
test.cc: In constructor ‘constexpr C::C()’:
test.cc:6:20: sorry, unimplemented: use of the value of the object being
constructed in a constant expression
constexpr C() {}
and indeed, if `int b = a + 1;` is changed to `int b = 3;`, G++ accepts it.
>From gcc-bugs-return-425769-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Jul 04 18:03:54 2013
Return-Path: <gcc-bugs-return-425769-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 20233 invoked by alias); 4 Jul 2013 18:03:54 -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 20183 invoked by uid 55); 4 Jul 2013 18:03:49 -0000
From: "dean at arctic dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/29776] result of ffs/clz/ctz/popcount/parity are already sign-extended
Date: Thu, 04 Jul 2013 18:03:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: target
X-Bugzilla-Version: 4.3.0
X-Bugzilla-Keywords: missed-optimization
X-Bugzilla-Severity: normal
X-Bugzilla-Who: dean at arctic dot org
X-Bugzilla-Status: NEW
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-29776-4-dWGqXfuTPA@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-29776-4@http.gcc.gnu.org/bugzilla/>
References: <bug-29776-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: 2013-07/txt/msg00276.txt.bz2
Content-length: 645
http://gcc.gnu.org/bugzilla/show_bug.cgi?id)776
--- Comment #10 from dean at arctic dot org ---
On Thu, 4 Jul 2013, jakub at gcc dot gnu.org wrote:
> I'm not 100% sure about CLZ/CTZ in the patch, because it could return any value
> for argument of 0, but as we document it as undefined behavior, perhaps it is
> fine.
this is unfortunate really -- the newer LZCNT/TZCNT instructions on x86
explicitly return 8*sizeof(type) for input of zero because the undefined
behaviour of BSF/BSR posed a lot of problems in inner loops. it might be
useful to add explicit builtins for this behaviour.
thanks for taking a look at the bug :)
-dean
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/57820] Can't initialize a constexpr object with inline initialization
2013-07-04 9:45 [Bug c++/57820] New: Can't initialize a constexpr object with inline initialization liweifriends at gmail dot com
2013-07-04 9:57 ` [Bug c++/57820] " redi at gcc dot gnu.org
2013-07-04 17:46 ` harald at gigawatt dot nl
@ 2014-11-03 10:40 ` paolo.carlini at oracle dot com
2014-11-03 10:49 ` paolo at gcc dot gnu.org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: paolo.carlini at oracle dot com @ 2014-11-03 10:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57820
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |accepts-invalid
--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> ---
AFAICS, in mainline this is now an accepts-invalid, because we accept
submitter's testcase too as-is.
I'm going to add to the testsuite the valid variants in Comments 1 & 2.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/57820] Can't initialize a constexpr object with inline initialization
2013-07-04 9:45 [Bug c++/57820] New: Can't initialize a constexpr object with inline initialization liweifriends at gmail dot com
` (2 preceding siblings ...)
2014-11-03 10:40 ` paolo.carlini at oracle dot com
@ 2014-11-03 10:49 ` paolo at gcc dot gnu.org
2014-11-20 12:57 ` [Bug c++/57820] [DR 253] NSDMI and const objects jason at gcc dot gnu.org
2024-04-04 0:21 ` pinskia at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: paolo at gcc dot gnu.org @ 2014-11-03 10:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57820
--- Comment #4 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> ---
Author: paolo
Date: Mon Nov 3 10:49:05 2014
New Revision: 217035
URL: https://gcc.gnu.org/viewcvs?rev=217035&root=gcc&view=rev
Log:
2014-11-03 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/57820
* g++.dg/cpp0x/constexpr-ctor16.C: New.
* g++.dg/cpp0x/constexpr-ctor17.C: Likewise.
Added:
trunk/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor16.C
trunk/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor17.C
Modified:
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/57820] [DR 253] NSDMI and const objects
2013-07-04 9:45 [Bug c++/57820] New: Can't initialize a constexpr object with inline initialization liweifriends at gmail dot com
` (3 preceding siblings ...)
2014-11-03 10:49 ` paolo at gcc dot gnu.org
@ 2014-11-20 12:57 ` jason at gcc dot gnu.org
2024-04-04 0:21 ` pinskia at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: jason at gcc dot gnu.org @ 2014-11-20 12:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57820
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |SUSPENDED
CC| |jason at gcc dot gnu.org
Summary|Can't initialize a |[DR 253] NSDMI and const
|constexpr object with |objects
|inline initialization |
--- Comment #5 from Jason Merrill <jason at gcc dot gnu.org> ---
This issue is DR 253, which has not been resolved, but the committee seems
inclined to allow this code, so I'm not going to change G++ at this time.
http://www.open-std.org/JTC1/SC22/WG21/docs/cwg_toc.html#253
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/57820] [DR 253] NSDMI and const objects
2013-07-04 9:45 [Bug c++/57820] New: Can't initialize a constexpr object with inline initialization liweifriends at gmail dot com
` (4 preceding siblings ...)
2014-11-20 12:57 ` [Bug c++/57820] [DR 253] NSDMI and const objects jason at gcc dot gnu.org
@ 2024-04-04 0:21 ` pinskia at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-04-04 0:21 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57820
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|SUSPENDED |NEW
--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
[Adopted at the November, 2016 meeting as part of paper P0490R0.]
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-04-04 0:21 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-04 9:45 [Bug c++/57820] New: Can't initialize a constexpr object with inline initialization liweifriends at gmail dot com
2013-07-04 9:57 ` [Bug c++/57820] " redi at gcc dot gnu.org
2013-07-04 17:46 ` harald at gigawatt dot nl
2014-11-03 10:40 ` paolo.carlini at oracle dot com
2014-11-03 10:49 ` paolo at gcc dot gnu.org
2014-11-20 12:57 ` [Bug c++/57820] [DR 253] NSDMI and const objects jason at gcc dot gnu.org
2024-04-04 0:21 ` pinskia 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).