public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/13051] New: problem with static member and ?: operator
@ 2003-11-14 14:46 mihai_preda at yahoo dot com
2003-11-14 14:53 ` [Bug c++/13051] " bangerth at dealii dot org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: mihai_preda at yahoo dot com @ 2003-11-14 14:46 UTC (permalink / raw)
To: gcc-bugs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1971 bytes --]
class A {
public:
static const int a = 1;
static const int b = 2;
};
int main(int argc) {
return (argc == 0) ? A::a : A::b;
/*
if (argc == 0) {
return A::a;
} else {
return A::b;
}
*/
}
when linking, I get
/tmp/ccEecr0u.o: In function `main':
/tmp/ccEecr0u.o(.text+0x17): undefined reference to `A::b'
/tmp/ccEecr0u.o(.text+0x21): undefined reference to `A::a'
But when I use the commented-out 'if' instead of '?:', it compiles&links OK.
$g++ -v
Lecture des spécification à partir de
/xyleme/Linux/gcc3/usr/gcc/lib/gcc-lib/i686-pc-linux-gnu/3.2.3/specs
Configuré avec: ./configure --prefix=/xyleme/Linux/gcc3/usr/gcc --enable-threads
Modèle de thread: posix
version gcc 3.2.3
$uname -a
Linux xxx 2.4.18-64GB-SMP #1 SMP Wed Mar 27 13:58:12 UTC 2002 i686 unknown
--
Summary: problem with static member and ?: operator
Product: gcc
Version: 3.2.3
Status: UNCONFIRMED
Severity: minor
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: mihai_preda at yahoo dot com
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13051
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/13051] problem with static member and ?: operator
2003-11-14 14:46 [Bug c++/13051] New: problem with static member and ?: operator mihai_preda at yahoo dot com
@ 2003-11-14 14:53 ` bangerth at dealii dot org
2003-11-14 15:47 ` mihai_preda at yahoo dot com
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: bangerth at dealii dot org @ 2003-11-14 14:53 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2003-11-14 14:53 -------
This is one of the most often reported non-bugs. You need to
have a _definition_ of the static member, not only a declaration.
Add the lines
const int A::a;
const int A::b;
to your program and everything should be ok.
W.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13051
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/13051] problem with static member and ?: operator
2003-11-14 14:46 [Bug c++/13051] New: problem with static member and ?: operator mihai_preda at yahoo dot com
2003-11-14 14:53 ` [Bug c++/13051] " bangerth at dealii dot org
@ 2003-11-14 15:47 ` mihai_preda at yahoo dot com
2003-11-14 16:12 ` bangerth at dealii dot org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: mihai_preda at yahoo dot com @ 2003-11-14 15:47 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From mihai_preda at yahoo dot com 2003-11-14 15:47 -------
I know that the static inside the class is only a declaration, and not a definition.
But it seems that, in this situation, a definition should not be needed at all.
That's why I gave the "if" alternative (in the commented block) which links just
fine without any definition of the static members.
What I consider as a bug is the different behavior of the "?:" from the "if"
equivalent. IMO the "?:" should behave the same way "if" does ("if" doesn't
require the definition).
Thanks
--
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |UNCONFIRMED
Resolution|INVALID |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13051
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/13051] problem with static member and ?: operator
2003-11-14 14:46 [Bug c++/13051] New: problem with static member and ?: operator mihai_preda at yahoo dot com
2003-11-14 14:53 ` [Bug c++/13051] " bangerth at dealii dot org
2003-11-14 15:47 ` mihai_preda at yahoo dot com
@ 2003-11-14 16:12 ` bangerth at dealii dot org
2005-04-28 2:03 ` pinskia at gcc dot gnu dot org
2005-04-28 2:07 ` pinskia at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: bangerth at dealii dot org @ 2003-11-14 16:12 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2003-11-14 16:12 -------
The compiler is still allowed to require a definition. That's
what the standard says, so there is no bug here.
That being said, I think Mark fixed this a while ago on
mainline. At least it compiles on mainline.
W.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13051
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/13051] problem with static member and ?: operator
2003-11-14 14:46 [Bug c++/13051] New: problem with static member and ?: operator mihai_preda at yahoo dot com
` (2 preceding siblings ...)
2003-11-14 16:12 ` bangerth at dealii dot org
@ 2005-04-28 2:03 ` pinskia at gcc dot gnu dot org
2005-04-28 2:07 ` pinskia at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-04-28 2:03 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-04-28 02:02 -------
reopening to ....
--
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |UNCONFIRMED
Resolution|INVALID |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13051
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/13051] problem with static member and ?: operator
2003-11-14 14:46 [Bug c++/13051] New: problem with static member and ?: operator mihai_preda at yahoo dot com
` (3 preceding siblings ...)
2005-04-28 2:03 ` pinskia at gcc dot gnu dot org
@ 2005-04-28 2:07 ` pinskia at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-04-28 2:07 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-04-28 02:03 -------
Mark as a dup of bug 14404.
*** This bug has been marked as a duplicate of 14404 ***
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |DUPLICATE
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13051
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2005-04-28 2:03 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-11-14 14:46 [Bug c++/13051] New: problem with static member and ?: operator mihai_preda at yahoo dot com
2003-11-14 14:53 ` [Bug c++/13051] " bangerth at dealii dot org
2003-11-14 15:47 ` mihai_preda at yahoo dot com
2003-11-14 16:12 ` bangerth at dealii dot org
2005-04-28 2:03 ` pinskia at gcc dot gnu dot org
2005-04-28 2:07 ` pinskia at gcc dot gnu dot 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).