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

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).