listhelper-moderate
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

help-gplusplus post from address@hidden requires approval


From: help-gplusplus-owner
Subject: help-gplusplus post from address@hidden requires approval
Date: Wed, 27 Jun 2007 14:40:10 -0400

As list administrator, your authorization is requested for the
following mailing list posting:

    List:    address@hidden
    From:    address@hidden
    Subject: bizarre backtrace when trying to initialize std::map with 
std::pair array
    Reason:  Post by non-member to a members-only list

At your convenience, visit:

    http://lists.gnu.org/mailman/admindb/help-gplusplus
        
to approve or deny the request.
--- Begin Message --- Subject: bizarre backtrace when trying to initialize std::map with std::pair array Date: Wed, 27 Jun 2007 18:17:57 -0000 User-agent: G2/1.0
I'm trying to initialize a std::map with an array of std::pair, but it
causes a sigsegv.  I'm using GCC 3.4.6 on RHEL 4.4 x86_64.

My gdb backtrace, a snippet of stl_map.h, and my program are included
below.  For better formatted display, see http://paste.collinslabs.com/?show=30.
Notice in particular the values of the parameters to the map
constructor and the insert_unique() function in frames #3 and #2,
respectively.  Why is __first in the map constructor one thing, and
__first in the insert_unique function another?

   1.
      /* map.cpp */
   2.
      #include <iostream>
   3.
      #include <map>
   4.
      #include <string>
   5.
      #include <utility>
   6.
      #include <vector>
   7.

   8.
      namespace {
   9.
        void f() {}
  10.
        void g() {}
  11.

  12.
        typedef std::pair<std::string, void (*)()> mypair_t;
  13.

  14.
        mypair_t pairs[] =
  15.
          {
  16.
            mypair_t("f", &f),
  17.
            mypair_t("g", &g)
  18.
          };
  19.
      }
  20.

  21.
      int main()
  22.
      {
  23.
        std::map<std::string, void (*)()> mymap(pairs, pairs
+sizeof(pairs));
  24.
      }
  25.

  26.

  27.
      /* stl_map.h line 180-ish (libstdc++ 3.3.5) */
  28.
            template <typename _InputIterator>
  29.
              map(_InputIterator __first, _InputIterator __last)
  30.
              : _M_t(_Compare(), allocator_type())
  31.
            { _M_t.insert_unique(__first, __last); }
  32.

  33.
      /* gdb backtrace
  34.
 
********************************************************************************
  35.
      #0  0x00000033448903a9 in std::basic_string<char,
std::char_traits<char>, std::\
  36.
      allocator<char> >::basic_string () from /usr/lib64/libstdc++.so.
6
  37.
      #1  0x00000000004012af in pair<std::string, void (*)()>
(this=0x7fbffff510,
  38.
          address@hidden)
  39.
          at /usr/lib/gcc/x86_64-redhat-linux/3.4.6/../../../../
include/c++/3.4.6/bit\
  40.
      s/stl_pair.h:90
  41.
      #2  0x0000000000401100 in std::_Rb_tree<std::string,
std::pair<std::string cons\
  42.
      t, void (*)()>, std::_Select1st<std::pair<std::string const,
void (*)()> >, std\
  43.
      ::less<std::string>, std::allocator<std::pair<std::string const,
void (*)()> > \
  44.
      >::insert_unique<std::pair<std::string, void (*)()>*>
(this=0x7fbffff5d0,
  45.
          __first=0x502bc0, __last=0x502da0)
  46.
          at /usr/lib/gcc/x86_64-redhat-linux/3.4.6/../../../../
include/c++/3.4.6/bit\
  47.
      s/stl_tree.h:996
  48.
      #3  0x0000000000400faf in map<<unnamed>::mypair_t*>
(this=0x7fbffff5d0,
  49.
          __first=0x502ba0, __last=0x502da0)
  50.
          at /usr/lib/gcc/x86_64-redhat-linux/3.4.6/../../../../
include/c++/3.4.6/bit\
  51.
      s/stl_map.h:180
  52.
      #4  0x0000000000400d66 in main () at map.cpp:22
  53.
 
*******************************************************************************
  54.
      */


--- End Message ---
--- Begin Message --- Subject: confirm 3ada2b351e97066bbaf1a2dad7872b8e58639b14
If you reply to this message, keeping the Subject: header intact,
Mailman will discard the held message.  Do this if the message is
spam.  If you reply to this message and include an Approved: header
with the list password in it, the message will be approved for posting
to the list.  The Approved: header can also appear in the first line
of the body of the reply.

--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]