public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/23147] New: Missing declaration of static const members
@ 2005-07-30 10:57 fw at deneb dot enyo dot de
2005-07-30 13:45 ` [Bug c++/23147] " falk at debian dot org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: fw at deneb dot enyo dot de @ 2005-07-30 10:57 UTC (permalink / raw)
To: gcc-bugs
The program below compiles cleanly with GCC 4.0.1, although the definition of
Foo::foo required by the standard (9.4.2/4) is missing.
It probably makes sense to accept such programs as a GNU extension (as long as
the address of the member is not taken).
#include <cstdio>
struct Foo
{
static const int foo = 42;
};
int
main ()
{
std::printf ("%d\n", Foo::foo);
return 0;
}
--
Summary: Missing declaration of static const members
Product: gcc
Version: 4.0.1
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: fw at deneb dot enyo dot de
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23147
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/23147] Missing declaration of static const members
2005-07-30 10:57 [Bug c++/23147] New: Missing declaration of static const members fw at deneb dot enyo dot de
@ 2005-07-30 13:45 ` falk at debian dot org
2005-07-30 15:11 ` fw at deneb dot enyo dot de
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: falk at debian dot org @ 2005-07-30 13:45 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From falk at debian dot org 2005-07-30 13:35 -------
Well, the behavior is undefined here, so what we currently do is just fine.
Moreover, this can only be detected at link time, so there's no way for us to
give a warning; at best, we could emit a fake reference and have the linker
hard fail. I don't think we want that, since it wastes space in the binary
for no really good reason other than being pedantic. So I'd say WONTFIX.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23147
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/23147] Missing declaration of static const members
2005-07-30 10:57 [Bug c++/23147] New: Missing declaration of static const members fw at deneb dot enyo dot de
2005-07-30 13:45 ` [Bug c++/23147] " falk at debian dot org
@ 2005-07-30 15:11 ` fw at deneb dot enyo dot de
2005-07-30 15:20 ` pinskia at gcc dot gnu dot org
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: fw at deneb dot enyo dot de @ 2005-07-30 15:11 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From fw at deneb dot enyo dot de 2005-07-30 13:45 -------
What about a GNU extension which would make this program well-formed? I think
it's quite a common pattern, and a requirement to provide a definition would
just increase object code size meaninglessly.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23147
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/23147] Missing declaration of static const members
2005-07-30 10:57 [Bug c++/23147] New: Missing declaration of static const members fw at deneb dot enyo dot de
2005-07-30 13:45 ` [Bug c++/23147] " falk at debian dot org
2005-07-30 15:11 ` fw at deneb dot enyo dot de
@ 2005-07-30 15:20 ` pinskia at gcc dot gnu dot org
2005-07-31 9:51 ` fw at deneb dot enyo dot de
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-07-30 15:20 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-07-30 15:13 -------
Actually the compiler is allowed to "inlined" the value of the constant. And the missing definition does
not have to be diagnostic.
So closing as invalid.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23147
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/23147] Missing declaration of static const members
2005-07-30 10:57 [Bug c++/23147] New: Missing declaration of static const members fw at deneb dot enyo dot de
` (2 preceding siblings ...)
2005-07-30 15:20 ` pinskia at gcc dot gnu dot org
@ 2005-07-31 9:51 ` fw at deneb dot enyo dot de
2005-07-31 13:31 ` falk at debian dot org
2005-08-05 21:43 ` fw at deneb dot enyo dot de
5 siblings, 0 replies; 7+ messages in thread
From: fw at deneb dot enyo dot de @ 2005-07-31 9:51 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From fw at deneb dot enyo dot de 2005-07-31 09:25 -------
What about permitting this as a GNU extension? It seems quite useful for
template code.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23147
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/23147] Missing declaration of static const members
2005-07-30 10:57 [Bug c++/23147] New: Missing declaration of static const members fw at deneb dot enyo dot de
` (3 preceding siblings ...)
2005-07-31 9:51 ` fw at deneb dot enyo dot de
@ 2005-07-31 13:31 ` falk at debian dot org
2005-08-05 21:43 ` fw at deneb dot enyo dot de
5 siblings, 0 replies; 7+ messages in thread
From: falk at debian dot org @ 2005-07-31 13:31 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From falk at debian dot org 2005-07-31 13:31 -------
(In reply to comment #4)
> What about permitting this as a GNU extension? It seems quite useful for
> template code.
With "this" you mean omitting the definition? Well, it saves one line of
typing, but I'm not really convinced that justifies an extension.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23147
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/23147] Missing declaration of static const members
2005-07-30 10:57 [Bug c++/23147] New: Missing declaration of static const members fw at deneb dot enyo dot de
` (4 preceding siblings ...)
2005-07-31 13:31 ` falk at debian dot org
@ 2005-08-05 21:43 ` fw at deneb dot enyo dot de
5 siblings, 0 replies; 7+ messages in thread
From: fw at deneb dot enyo dot de @ 2005-08-05 21:43 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From fw at deneb dot enyo dot de 2005-08-05 21:43 -------
(In reply to comment #5)
> (In reply to comment #4)
>
> > What about permitting this as a GNU extension? It seems quite useful for
> > template code.
>
> With "this" you mean omitting the definition? Well, it saves one line of
> typing, but I'm not really convinced that justifies an extension.
I (incorrectly) feared that GCC would emit the constant for each template
instantiation. Therefore, I agree with you that no extension is necessary, and
the bug report was completely invalid. Sorry about that.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23147
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2005-08-05 21:43 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-30 10:57 [Bug c++/23147] New: Missing declaration of static const members fw at deneb dot enyo dot de
2005-07-30 13:45 ` [Bug c++/23147] " falk at debian dot org
2005-07-30 15:11 ` fw at deneb dot enyo dot de
2005-07-30 15:20 ` pinskia at gcc dot gnu dot org
2005-07-31 9:51 ` fw at deneb dot enyo dot de
2005-07-31 13:31 ` falk at debian dot org
2005-08-05 21:43 ` fw at deneb dot enyo dot de
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).