* value initialization and array data member
@ 2010-11-06 1:28 Gabriel Dos Reis
2010-11-06 2:24 ` Jason Merrill
0 siblings, 1 reply; 4+ messages in thread
From: Gabriel Dos Reis @ 2010-11-06 1:28 UTC (permalink / raw)
To: Jason Merrill; +Cc: GCC, libstdc++
Hi Jason,
I'm looking into std::bitset with respect to constexpr issue.
My understanding has always been that one can use the
syntax `member()' to value-initialize an array data member
`member'. However, std/biset uses the notation
`member({ })'. Is that required? Especially for a mem-initializer
in a constexpr constructor definition?
-- Gaby
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: value initialization and array data member
2010-11-06 1:28 value initialization and array data member Gabriel Dos Reis
@ 2010-11-06 2:24 ` Jason Merrill
2010-11-06 2:28 ` Paolo Carlini
0 siblings, 1 reply; 4+ messages in thread
From: Jason Merrill @ 2010-11-06 2:24 UTC (permalink / raw)
To: Gabriel Dos Reis; +Cc: GCC, libstdc++
On 11/05/2010 09:03 PM, Gabriel Dos Reis wrote:
> I'm looking into std::bitset with respect to constexpr issue.
> My understanding has always been that one can use the
> syntax `member()' to value-initialize an array data member
> `member'.
I believe so.
Jason
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: value initialization and array data member
2010-11-06 2:24 ` Jason Merrill
@ 2010-11-06 2:28 ` Paolo Carlini
2010-11-06 3:39 ` Paolo Carlini
0 siblings, 1 reply; 4+ messages in thread
From: Paolo Carlini @ 2010-11-06 2:28 UTC (permalink / raw)
To: Jason Merrill; +Cc: Gabriel Dos Reis, GCC, libstdc++
[-- Attachment #1: Type: text/plain, Size: 1787 bytes --]
Hi,
> On 11/05/2010 09:03 PM, Gabriel Dos Reis wrote:
>> I'm looking into std::bitset with respect to constexpr issue.
>> My understanding has always been that one can use the
>> syntax `member()' to value-initialize an array data member
>> `member'.
> I believe so.
Thanks Gaby and Jason.
I wanted to apply the below patch, which seems correct to me in the
light of your exchange and triggered ICEs, for
23_containers/bitset/cons/constexpr.cc for example I got:
In file included from
/home/paolo/Gcc/svn-dirs/trunk/libstdc++-v3/testsuite/23_containers/bitset/cons/constexpr.cc:21:0:
/home/paolo/Gcc/svn-dirs/trunk-build/x86_64-unknown-linux-gnu/libstdc++-v3/include/bitset:
In constructor 'constexpr std::_Base_bitset<_Nw>::_Base_bitset() [with
long unsigned int _Nw = 4ul]':
/home/paolo/Gcc/svn-dirs/trunk-build/x86_64-unknown-linux-gnu/libstdc++-v3/include/bitset:814:7:
instantiated from 'constexpr std::bitset<_Nb>::bitset() [with long
unsigned int _Nb = 256ul]'
/home/paolo/Gcc/svn-dirs/trunk/libstdc++-v3/testsuite/util/testsuite_common_types.h:627:20:
instantiated from 'void
__gnu_test::constexpr_default_constructible::operator()()::_Concept::__constraint()
[with _Tp = std::bitset<256ul>]'
/home/paolo/Gcc/svn-dirs/trunk/libstdc++-v3/testsuite/util/testsuite_common_types.h:631:17:
instantiated from 'void
__gnu_test::constexpr_default_constructible::operator()() [with _Tp =
std::bitset<256ul>]'
/home/paolo/Gcc/svn-dirs/trunk/libstdc++-v3/testsuite/23_containers/bitset/cons/constexpr.cc:29:38:
instantiated from here
/home/paolo/Gcc/svn-dirs/trunk-build/x86_64-unknown-linux-gnu/libstdc++-v3/include/bitset:76:18:
internal compiler error: in build_data_member_initialization, at
cp/semantics.c:5499
Can you have a look?
Thanks,
Paolo.
//////////////////////
[-- Attachment #2: patchlet --]
[-- Type: text/plain, Size: 864 bytes --]
Index: include/std/bitset
===================================================================
--- include/std/bitset (revision 166384)
+++ include/std/bitset (working copy)
@@ -72,9 +72,10 @@
/// 0 is the least significant word.
_WordT _M_w[_Nw];
-#ifdef __GXX_EXPERIMENTAL_CXX0X__
- constexpr _Base_bitset() : _M_w({ }) { }
+ _GLIBCXX_CONSTEXPR _Base_bitset()
+ : _M_w() { }
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
constexpr _Base_bitset(unsigned long long __val)
: _M_w({ _WordT(__val)
#if __SIZEOF_LONG_LONG__ > __SIZEOF_LONG__
@@ -82,14 +83,9 @@
#endif
}) { }
#else
- _Base_bitset()
- { _M_do_reset(); }
-
_Base_bitset(unsigned long __val)
- {
- _M_do_reset();
- _M_w[0] = __val;
- }
+ : _M_w()
+ { _M_w[0] = __val; }
#endif
static _GLIBCXX_CONSTEXPR size_t
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: value initialization and array data member
2010-11-06 2:28 ` Paolo Carlini
@ 2010-11-06 3:39 ` Paolo Carlini
0 siblings, 0 replies; 4+ messages in thread
From: Paolo Carlini @ 2010-11-06 3:39 UTC (permalink / raw)
To: Jason Merrill; +Cc: Gabriel Dos Reis, GCC, libstdc++
... oh well, this is enough:
struct A
{
int arr[1];
constexpr A()
: arr() { }
};
Paolo.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-11-06 2:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-06 1:28 value initialization and array data member Gabriel Dos Reis
2010-11-06 2:24 ` Jason Merrill
2010-11-06 2:28 ` Paolo Carlini
2010-11-06 3:39 ` Paolo Carlini
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).