public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: bangerth@ticam.utexas.edu
To: gcc-gnats@gcc.gnu.org
Subject: c++/8797: g++ accepts in-class initialization of non-integral static member
Date: Tue, 03 Dec 2002 07:46:00 -0000	[thread overview]
Message-ID: <20021203154336.19525.qmail@sources.redhat.com> (raw)


>Number:         8797
>Category:       c++
>Synopsis:       g++ accepts in-class initialization of non-integral static member
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          accepts-illegal
>Submitter-Id:   net
>Arrival-Date:   Tue Dec 03 07:46:02 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Wolfgang Bangerth
>Release:        unknown-1.0
>Organization:
>Environment:
2.95 through 3.3CVS, Linux (but front end matter anyway)
>Description:
Based on the discussion on PR 8778 (to be found in the audit
trail of that report):

gcc accepts this although the standard says that only 
integral _scalars_ can be initialized in-class:
-----------------------------
struct A {
    static const int i[] = { 1,2 };
};
-----------------------------
I _do_ get a warning if I use -pedantic. However, I maintain
that I should get an unconditional _error_ instead.

On the other hand, if this is a gcc extension, it should
- be documented in the manual
- generate an _error_ on -pedantic -ansi


To make things a little worse: templatizing the class like
---------------------------------------
template <int> struct A {
    static const int i[] = { 1,2 };
};

template struct A<1>;
---------------------------------------
yields the following, slightly convoluted error message
stating the same content twice in different words:

tmp/g> /home/bangerth/bin/gcc-3.3-pre/bin/c++ -pedantic -ansi -c x.cc
x.cc:2: warning: ISO C++ forbids initialization of member constant `i' of
   non-integral type `const int[]'
x.cc: In instantiation of `A<1>':
x.cc:5:   instantiated from here
x.cc:2: warning: ISO C++ forbids initialization of member constant `A<1>::i' of
   non-integral type `const int[2]'
>How-To-Repeat:

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


             reply	other threads:[~2002-12-03 15:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-03  7:46 bangerth [this message]
2003-01-13 23:26 reichelt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20021203154336.19525.qmail@sources.redhat.com \
    --to=bangerth@ticam.utexas.edu \
    --cc=gcc-gnats@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).