public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/38233]  New: 'map' value type + new uninitted const member warnings causes error
@ 2008-11-23  8:47 cgd at google dot com
  2008-11-23  8:49 ` [Bug libstdc++/38233] " cgd at google dot com
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: cgd at google dot com @ 2008-11-23  8:47 UTC (permalink / raw)
  To: gcc-bugs

Consider the code:

#include <map>

class a {
 public:
  a();
};

class b {
 public:
  // implicit default ctor
  bool operator<(const b& rhs) const;

 private:
  a a_val;
};

typedef std::map<b, int> my_map;

void func() {
  my_map::value_type x;
}


That compiled correctly with 4.3.2.  It fails to compile with pre-4.4 trunk:

Using built-in specs.
Target: i686-linux
Configured with: ../trunk/configure --enable-languages=c,c++ --build=i686-linux
--host=i686-linux --target=i686-linux
--prefix=/g/users/cgd/proj/gcc-trunk/bld/../inst
Thread model: posix
gcc version 4.4.0 20081123 (experimental) (GCC) 

with the error:

In file included from
[...]/bin/../lib/gcc/i686-linux/4.4.0/../../../../include/c++/4.4.0/bits/stl_algobase.h:71,
                 from
[...]/bin/../lib/gcc/i686-linux/4.4.0/../../../../include/c++/4.4.0/bits/stl_tree.h:67,
                 from
[...]/bin/../lib/gcc/i686-linux/4.4.0/../../../../include/c++/4.4.0/map:65,
                 from test2.cc:1:
[...]/bin/../lib/gcc/i686-linux/4.4.0/../../../../include/c++/4.4.0/bits/stl_pair.h:
In constructor 'std::pair<_T1, _T2>::pair() [with _T1 = const b, _T2 = int]':
test2.cc:20:   instantiated from here
[...]/bin/../lib/gcc/i686-linux/4.4.0/../../../../include/c++/4.4.0/bits/stl_pair.h:84:
error: uninitialized member 'std::pair<const b, int>::first' with 'const' type
'const b'


Looking at the preprocessed source (which i'll attach shortly), I see that
pair's default ctor is:

      pair()
      : first(), second() { }

I don't know if that's "right," but the C++98 std says that:

"Initializes its members as if implemented: pair() : first(T1()), second(T2())
{}"

(20.2.2, paragraph 2.)

If I change the pair() ctor to be:

      pair()
      : first(_T1()), second(_T2()) { }

(by hacking the preprocessed source), the result compiles correctly.

(I'm *so* far from an expert on STL that I'm not 100% sure that sample code is
actually valid, but on its face it seems reasonable at least, and 4.3.x
accepted it, and Comeau's test drive accepts it as well.)


-- 
           Summary: 'map' value type + new uninitted const member warnings
                    causes error
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: cgd at google dot com
 GCC build triplet: i686-linux
  GCC host triplet: i686-linux
GCC target triplet: i686-linux


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


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

* [Bug libstdc++/38233] 'map' value type + new uninitted const member warnings causes error
  2008-11-23  8:47 [Bug libstdc++/38233] New: 'map' value type + new uninitted const member warnings causes error cgd at google dot com
@ 2008-11-23  8:49 ` cgd at google dot com
  2008-11-23 12:23 ` [Bug libstdc++/38233] [4.4 Regression] " rguenth at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: cgd at google dot com @ 2008-11-23  8:49 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from cgd at google dot com  2008-11-23 08:48 -------
Created an attachment (id=16750)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=16750&action=view)
preprocessed source from test case in bug report.


-- 


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


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

* [Bug libstdc++/38233] [4.4 Regression] 'map' value type + new uninitted const member warnings causes error
  2008-11-23  8:47 [Bug libstdc++/38233] New: 'map' value type + new uninitted const member warnings causes error cgd at google dot com
  2008-11-23  8:49 ` [Bug libstdc++/38233] " cgd at google dot com
@ 2008-11-23 12:23 ` rguenth at gcc dot gnu dot org
  2008-11-23 14:43 ` pinskia at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-11-23 12:23 UTC (permalink / raw)
  To: gcc-bugs



-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
      Known to work|                            |4.3.2
            Summary|'map' value type + new      |[4.4 Regression] 'map' value
                   |uninitted const member      |type + new uninitted const
                   |warnings causes error       |member warnings causes error
   Target Milestone|---                         |4.4.0


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


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

* [Bug libstdc++/38233] [4.4 Regression] 'map' value type + new uninitted const member warnings causes error
  2008-11-23  8:47 [Bug libstdc++/38233] New: 'map' value type + new uninitted const member warnings causes error cgd at google dot com
  2008-11-23  8:49 ` [Bug libstdc++/38233] " cgd at google dot com
  2008-11-23 12:23 ` [Bug libstdc++/38233] [4.4 Regression] " rguenth at gcc dot gnu dot org
@ 2008-11-23 14:43 ` pinskia at gcc dot gnu dot org
  2008-11-24 11:11 ` paolo dot carlini at oracle dot com
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-11-23 14:43 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2008-11-23 14:41 -------
There is a defect report which changed C++98 dealing with default
initialization which might be causing this issue, see DR178.


-- 


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


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

* [Bug libstdc++/38233] [4.4 Regression] 'map' value type + new uninitted const member warnings causes error
  2008-11-23  8:47 [Bug libstdc++/38233] New: 'map' value type + new uninitted const member warnings causes error cgd at google dot com
                   ` (2 preceding siblings ...)
  2008-11-23 14:43 ` pinskia at gcc dot gnu dot org
@ 2008-11-24 11:11 ` paolo dot carlini at oracle dot com
  2008-11-26  9:40 ` [Bug c++/38233] " paolo dot carlini at oracle dot com
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: paolo dot carlini at oracle dot com @ 2008-11-24 11:11 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from paolo dot carlini at oracle dot com  2008-11-24 11:10 -------
The default constructor of pair just implements DR 265, this is *very* old:

  http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#265

This is possibly a C++ front-end issue, because lately nothing changed in the
library in this area. I'll CC Jason.


-- 

paolo dot carlini at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu dot org


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


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

* [Bug c++/38233] [4.4 Regression] 'map' value type + new uninitted const member warnings causes error
  2008-11-23  8:47 [Bug libstdc++/38233] New: 'map' value type + new uninitted const member warnings causes error cgd at google dot com
                   ` (3 preceding siblings ...)
  2008-11-24 11:11 ` paolo dot carlini at oracle dot com
@ 2008-11-26  9:40 ` paolo dot carlini at oracle dot com
  2008-11-26 20:12 ` jason at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: paolo dot carlini at oracle dot com @ 2008-11-26  9:40 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from paolo dot carlini at oracle dot com  2008-11-26 09:39 -------
The below is a pure C++ testcase, which EDG accepts and mainline rejects. Jason
can you look a bit into it? Thanks in advance!

////////////////

template<class _T1, class _T2>
  struct pair
  {
    _T1 first;
    _T2 second;

    // _GLIBCXX_RESOLVE_LIB_DEFECTS
    // 265.  std::pair::pair() effects overly restrictive
    /** The default constructor creates @c first and @c second using their
     *  respective default constructors.  */
    pair()
    : first(), second() { }
};

class a {
 public:
  a();
};

class b {
 public:
  // implicit default ctor
  bool operator<(const b& rhs) const;

 private:
  a a_val;
};

typedef pair<const b, int> my_pair;

void func() {
  my_pair x;
}


-- 

paolo dot carlini at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
          Component|libstdc++                   |c++
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2008-11-26 09:39:19
               date|                            |


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


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

* [Bug c++/38233] [4.4 Regression] 'map' value type + new uninitted const member warnings causes error
  2008-11-23  8:47 [Bug libstdc++/38233] New: 'map' value type + new uninitted const member warnings causes error cgd at google dot com
                   ` (4 preceding siblings ...)
  2008-11-26  9:40 ` [Bug c++/38233] " paolo dot carlini at oracle dot com
@ 2008-11-26 20:12 ` jason at gcc dot gnu dot org
  2008-11-28 23:38 ` jason at gcc dot gnu dot org
  2008-11-28 23:40 ` jason at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: jason at gcc dot gnu dot org @ 2008-11-26 20:12 UTC (permalink / raw)
  To: gcc-bugs



-- 

jason at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |jason at gcc dot gnu dot org
                   |dot org                     |
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2008-11-26 09:39:19         |2008-11-26 20:10:57
               date|                            |


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


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

* [Bug c++/38233] [4.4 Regression] 'map' value type + new uninitted const member warnings causes error
  2008-11-23  8:47 [Bug libstdc++/38233] New: 'map' value type + new uninitted const member warnings causes error cgd at google dot com
                   ` (5 preceding siblings ...)
  2008-11-26 20:12 ` jason at gcc dot gnu dot org
@ 2008-11-28 23:38 ` jason at gcc dot gnu dot org
  2008-11-28 23:40 ` jason at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: jason at gcc dot gnu dot org @ 2008-11-28 23:38 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from jason at gcc dot gnu dot org  2008-11-28 23:36 -------
Subject: Bug 38233

Author: jason
Date: Fri Nov 28 23:35:37 2008
New Revision: 142265

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=142265
Log:
        PR c++/38233
        * init.c (perform_member_init): Fix value-initialization.
        (build_value_init_1): Add assert to catch cases that will break
        in the gimplifier.
        (build_default_init): Remove.
        * cp-tree.h: Remove its prototype.
        * pt.c (tsubst_expr) [DECL_EXPR]: Use build_value_init for
        value-initialization.

Added:
    trunk/gcc/testsuite/g++.dg/init/array25.C
    trunk/gcc/testsuite/g++.dg/init/value4.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/cp-tree.h
    trunk/gcc/cp/init.c
    trunk/gcc/cp/pt.c
    trunk/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug c++/38233] [4.4 Regression] 'map' value type + new uninitted const member warnings causes error
  2008-11-23  8:47 [Bug libstdc++/38233] New: 'map' value type + new uninitted const member warnings causes error cgd at google dot com
                   ` (6 preceding siblings ...)
  2008-11-28 23:38 ` jason at gcc dot gnu dot org
@ 2008-11-28 23:40 ` jason at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: jason at gcc dot gnu dot org @ 2008-11-28 23:40 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from jason at gcc dot gnu dot org  2008-11-28 23:39 -------
Fixed.


-- 

jason at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


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


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

end of thread, other threads:[~2008-11-28 23:40 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-23  8:47 [Bug libstdc++/38233] New: 'map' value type + new uninitted const member warnings causes error cgd at google dot com
2008-11-23  8:49 ` [Bug libstdc++/38233] " cgd at google dot com
2008-11-23 12:23 ` [Bug libstdc++/38233] [4.4 Regression] " rguenth at gcc dot gnu dot org
2008-11-23 14:43 ` pinskia at gcc dot gnu dot org
2008-11-24 11:11 ` paolo dot carlini at oracle dot com
2008-11-26  9:40 ` [Bug c++/38233] " paolo dot carlini at oracle dot com
2008-11-26 20:12 ` jason at gcc dot gnu dot org
2008-11-28 23:38 ` jason at gcc dot gnu dot org
2008-11-28 23:40 ` jason 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).