--- Comment #11 from pinskia at gcc dot gnu dot org 2006-09-25 21:11
---
*** Bug 29219 has been marked as a duplicate of this bug. ***
--
pinskia at gcc dot gnu dot org changed:
What|Removed |Added
-
--- Additional Comments From lerdsuwa at gcc dot gnu dot org 2005-03-20
13:55 ---
Here is the relevant section of the standard (TC1,
section 9.4.2, paragraph 4):
If a 'static' data member is of 'const' integral or 'const' enumeral type,
its declaration in the class definition can s
--- Additional Comments From Hu dot YuehWei at gmail dot com 2005-03-20
07:59 ---
so the "... = 3;" initialization statement below is a definition or a
declaration?
According to the C++ standard, its a definition.
Should the compiler allocate a memory space for it?
struct T
{
static
--- Additional Comments From pinskia at gcc dot gnu dot org 2005-03-19
18:35 ---
Bacause T::A is a lvalue.
--
What|Removed |Added
Status|UNCONFIRMED
--- Additional Comments From Hu dot YuehWei at gmail dot com 2005-03-19
18:25 ---
I see.
But why compiler doesn't also make a temporary variable for the constant defined
in a class scope?
Such as following codes:
struct T
{
static int const a = 3;
};
void
fff(int const &a)
{
}
int
m
--- Additional Comments From pinskia at gcc dot gnu dot org 2005-03-19
14:34 ---
(In reply to comment #5)
> I understand what you mean.
> But why the following codes works:
>
> #include
> #include
>
> struct T
> {
> static char const a = 3;
> };
>
> std::vector ddd;
>
> int
> mai
--- Additional Comments From Hu dot YuehWei at gmail dot com 2005-03-19
14:15 ---
I understand what you mean.
But why the following codes works:
#include
#include
struct T
{
static char const a = 3;
};
std::vector ddd;
int
main()
{
ddd.push_back(static_cast(T::a)); // <
--- Additional Comments From pinskia at gcc dot gnu dot org 2005-03-19
14:03 ---
(In reply to comment #2)
> But according the standard, 'const static' data members of an intergral type
> can
> now be initialized _inside_ their class. In this case, the initialization is
> _also_ a defini
--- Additional Comments From Hu dot YuehWei at gmail dot com 2005-03-19
14:01 ---
#include
struct T
{
static char const a = 3;
};
void
fff(char a)
{
}
std::vector b;
int
main()
{
fff(T::a); /* this line of codes is fine. */
b.push_back(T::a); /* however, this line of codes is
--- Additional Comments From Hu dot YuehWei at gmail dot com 2005-03-19
13:53 ---
But according the standard, 'const static' data members of an intergral type can
now be initialized _inside_ their class. In this case, the initialization is
_also_ a definition, so _no_ further definitions
--- Additional Comments From pinskia at gcc dot gnu dot org 2005-03-19
13:45 ---
No you need to add the following to your code:
const char T::a;
Since you don't supply the memory location otherwise (which is required by the
standard).
--
What|Removed
11 matches
Mail list logo