public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/28956]  New: Illegal array initialization accepted
@ 2006-09-05 20:35 ppluzhnikov at charter dot net
  2006-09-05 20:42 ` [Bug c++/28956] " pinskia at gcc dot gnu dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: ppluzhnikov at charter dot net @ 2006-09-05 20:35 UTC (permalink / raw)
  To: gcc-bugs

Consider:

struct Foo {
  Foo(); // comment out -> g++ fails with "error: invalid initializer"
};

void fn()
{
  Foo f[2];
  Foo g[2] = f;
}

The test above is accepted by g++ (tried 3.4.6, 4.0.0, 4.1.1 and 4.2-20060902).

EDG fails with:
$ edgcpfe pp.cpp
"pp.cpp", line 8: error: initialization with "{...}" expected for aggregate
          object
      Foo g[2] = f;
                 ^

1 error detected in the compilation of "pp.cpp".

Here is the original test case (also accepted by all versions of g++):

template <class T, class U>
struct pair {
    pair(const T& t, const U& u) : first(t), second(u) { }
    T first;
    U second;
};

struct Foo {
    Foo(); // comment out -> g++ fails with 
           // "error: ISO C++ forbids assignment of arrays"
};

int main()
{
    Foo f[2];
    pair<int, Foo[2]> p (1, f);
    return 0;
}

And analysis of it by William M. (Mike) Miller | Edison Design Group, Inc.:

> Could you please confirm that this is a g++ bug?

Yes, it's a bug.  The Standard (12.6.2 paragraph 3) defines an initialization
like "second(u)" to be direct-initialization as described in section 8.5. 
Section 8.5 paragraph 14 says that initialization of an array object is handled
in section 8.5.1. However, 8.5.1 does not provide for any way of initializing
an array from another array (except for the special case of a string literal,
8.5.2).  Arrays can only be initialized to a value using the brace notation,
which is not permitted in a mem-initializer.


-- 
           Summary: Illegal array initialization accepted
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ppluzhnikov at charter dot net
 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=28956


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/28956] Illegal array initialization accepted
  2006-09-05 20:35 [Bug c++/28956] New: Illegal array initialization accepted ppluzhnikov at charter dot net
@ 2006-09-05 20:42 ` pinskia at gcc dot gnu dot org
  2006-09-09  5:42 ` pinskia at gcc dot gnu dot org
  2006-10-12  1:49 ` bangerth at dealii dot org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-09-05 20:42 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2006-09-05 20:42 -------
There are two different bugs here, the first one is a regression from 3.2.3.
The second one is accepted by all versions of GCC I have access to from 2.95.3
and upwards.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28956


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/28956] Illegal array initialization accepted
  2006-09-05 20:35 [Bug c++/28956] New: Illegal array initialization accepted ppluzhnikov at charter dot net
  2006-09-05 20:42 ` [Bug c++/28956] " pinskia at gcc dot gnu dot org
@ 2006-09-09  5:42 ` pinskia at gcc dot gnu dot org
  2006-10-12  1:49 ` bangerth at dealii dot org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-09-09  5:42 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2006-09-09 05:42 -------
This is also related to PR 20039.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  BugsThisDependsOn|                            |20039


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28956


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/28956] Illegal array initialization accepted
  2006-09-05 20:35 [Bug c++/28956] New: Illegal array initialization accepted ppluzhnikov at charter dot net
  2006-09-05 20:42 ` [Bug c++/28956] " pinskia at gcc dot gnu dot org
  2006-09-09  5:42 ` pinskia at gcc dot gnu dot org
@ 2006-10-12  1:49 ` bangerth at dealii dot org
  2 siblings, 0 replies; 4+ messages in thread
From: bangerth at dealii dot org @ 2006-10-12  1:49 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from bangerth at dealii dot org  2006-10-12 01:49 -------
Confirmed.


-- 

bangerth at dealii dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2006-10-12 01:49:18
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28956


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-10-12  1:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-09-05 20:35 [Bug c++/28956] New: Illegal array initialization accepted ppluzhnikov at charter dot net
2006-09-05 20:42 ` [Bug c++/28956] " pinskia at gcc dot gnu dot org
2006-09-09  5:42 ` pinskia at gcc dot gnu dot org
2006-10-12  1:49 ` bangerth at dealii 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).