* [Bug c++/56251] no DW_AT_const_value for static const member of a template class
2013-02-08 4:06 [Bug c++/56251] New: no DW_AT_const_value for static const member of a template class chihin.ko at oracle dot com
@ 2013-02-08 4:09 ` pinskia at gcc dot gnu.org
2013-02-08 21:25 ` chihin.ko at oracle dot com
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2013-02-08 4:09 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56251
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> 2013-02-08 04:08:35 UTC ---
This code is invalid code.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/56251] no DW_AT_const_value for static const member of a template class
2013-02-08 4:06 [Bug c++/56251] New: no DW_AT_const_value for static const member of a template class chihin.ko at oracle dot com
2013-02-08 4:09 ` [Bug c++/56251] " pinskia at gcc dot gnu.org
@ 2013-02-08 21:25 ` chihin.ko at oracle dot com
2013-02-08 21:29 ` pinskia at gcc dot gnu.org
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: chihin.ko at oracle dot com @ 2013-02-08 21:25 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56251
--- Comment #2 from chihin ko <chihin.ko at oracle dot com> 2013-02-08 21:24:55 UTC ---
How is it invalid ? it was compilable and runnable:
benjamin2 906> /pkg/gnu/bin/g++ -v
Using built-in specs.
COLLECT_GCC=/pkg/gnu/bin/g++-4.7.1-5.10
COLLECT_LTO_WRAPPER=/pkg/gnu/libexec/gcc/i386-pc-solaris2.10/4.7.1/lto-wrapper
Target: i386-pc-solaris2.10
Configured with: ../gcc-4.7.1-src/configure --prefix=/pkg/gnu
--with-as=/pkg/gnu/bin/gas --with-gnu-as --enable-languages=c++,fortran
--enable-shared --enable-shared --with-gmp=/pkg/gnu --with-mpc=/pkg/local
--with-boot-ldflags=-R/pkg/local/lib:/pkg/gnu/lib --program-suffix=-4.7.1-5.10
Thread model: posix
gcc version 4.7.1 (GCC)
benjamin2 907> /pkg/gnu/bin/g++ -std=c++11 -R/pkg/gnu/lib t1.cc
benjamin2 908> a.out
tcc.value1 = 100
cc.value1 = 200
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/56251] no DW_AT_const_value for static const member of a template class
2013-02-08 4:06 [Bug c++/56251] New: no DW_AT_const_value for static const member of a template class chihin.ko at oracle dot com
2013-02-08 4:09 ` [Bug c++/56251] " pinskia at gcc dot gnu.org
2013-02-08 21:25 ` chihin.ko at oracle dot com
@ 2013-02-08 21:29 ` pinskia at gcc dot gnu.org
2013-02-08 22:02 ` chihin.ko at oracle dot com
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2013-02-08 21:29 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56251
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> 2013-02-08 21:28:25 UTC ---
You only declare the variable. There is no definition of the variable in the
program.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/56251] no DW_AT_const_value for static const member of a template class
2013-02-08 4:06 [Bug c++/56251] New: no DW_AT_const_value for static const member of a template class chihin.ko at oracle dot com
` (2 preceding siblings ...)
2013-02-08 21:29 ` pinskia at gcc dot gnu.org
@ 2013-02-08 22:02 ` chihin.ko at oracle dot com
2013-02-08 22:10 ` pinskia at gcc dot gnu.org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: chihin.ko at oracle dot com @ 2013-02-08 22:02 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56251
--- Comment #4 from chihin ko <chihin.ko at oracle dot com> 2013-02-08 22:01:36 UTC ---
Note, this is a const static member, the initialization is the definition,
if I don't initialize it, I would get an "Undefined symbol" linking error.
This code is valid.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/56251] no DW_AT_const_value for static const member of a template class
2013-02-08 4:06 [Bug c++/56251] New: no DW_AT_const_value for static const member of a template class chihin.ko at oracle dot com
` (3 preceding siblings ...)
2013-02-08 22:02 ` chihin.ko at oracle dot com
@ 2013-02-08 22:10 ` pinskia at gcc dot gnu.org
2013-02-08 22:51 ` paolo.carlini at oracle dot com
2013-02-10 16:00 ` daniel.kruegler at googlemail dot com
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2013-02-08 22:10 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56251
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> 2013-02-08 22:09:58 UTC ---
(In reply to comment #4)
> Note, this is a const static member, the initialization is the definition,
> if I don't initialize it, I would get an "Undefined symbol" linking error.
> This code is valid.
No, the code is invalid but a diagnostic is not required by the standard which
is why it is accepted.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/56251] no DW_AT_const_value for static const member of a template class
2013-02-08 4:06 [Bug c++/56251] New: no DW_AT_const_value for static const member of a template class chihin.ko at oracle dot com
` (4 preceding siblings ...)
2013-02-08 22:10 ` pinskia at gcc dot gnu.org
@ 2013-02-08 22:51 ` paolo.carlini at oracle dot com
2013-02-10 16:00 ` daniel.kruegler at googlemail dot com
6 siblings, 0 replies; 8+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-02-08 22:51 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56251
--- Comment #6 from Paolo Carlini <paolo.carlini at oracle dot com> 2013-02-08 22:50:35 UTC ---
See, eg, c++/30745 and many duplicates elsewhere.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/56251] no DW_AT_const_value for static const member of a template class
2013-02-08 4:06 [Bug c++/56251] New: no DW_AT_const_value for static const member of a template class chihin.ko at oracle dot com
` (5 preceding siblings ...)
2013-02-08 22:51 ` paolo.carlini at oracle dot com
@ 2013-02-10 16:00 ` daniel.kruegler at googlemail dot com
6 siblings, 0 replies; 8+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2013-02-10 16:00 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56251
Daniel Krügler <daniel.kruegler at googlemail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |daniel.kruegler at
| |googlemail dot com
--- Comment #7 from Daniel Krügler <daniel.kruegler at googlemail dot com> 2013-02-10 16:00:42 UTC ---
(In reply to comment #6)
I agree with Paolo and Andrew when considered as a potentially C++03 code, but
I would like to add that the example code is indeed valid in C++11, because
ellipsis functions such as printf have an lvalue-to-rvalue semantics for the
function arguments and the ODR rule has been revised to say
"A variable x whose name appears as a potentially-evaluated expression ex is
odr-used unless x is an object that satisfies the requirements for appearing in
a constant expression (5.19) and ex is an element of the set of potential
results of an expression e, where either the lvalue-to-rvalue conversion (4.1)
is applied
to e, or e is a discarded-value expression (Clause 5)."
Of-course this allowance doesn't require that an implementation needs to add
"DW_AT_const_value" for such static const members: The rule only reflects
existing practice that this use-case is no ODR-usage of CC::value or of
TCC<int, int>::tvalue, respectively.
^ permalink raw reply [flat|nested] 8+ messages in thread