This is the mail archive of the gcc-prs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

c++/1657: types weirdness (looks like memory corruption with -ggdb)



>Number:         1657
>Category:       c++
>Synopsis:       types weirdness (looks like memory corruption with -ggdb)
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Mon Jan 15 05:26:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Wolfgang Bangerth
>Release:        unknown-1.0
>Organization:
>Environment:
gcc CVS 2001-01-14 on Linux
>Description:
This reminds me of some kind of memory corruption:
deal.II/deal.II> cat ttt.cc
    #include <map>
    
    struct X {    const int x1[4];                 };
    struct Y {    std::map<int,int>::iterator y1;
                  int y2[4];                       };
    
    void f() {  std::map<int,Y> m; };

deal.II/deal.II> c++ -c ttt.cc -o /dev/null
deal.II/deal.II> c++ -ggdb -c ttt.cc -o /dev/null
    /home/people/wolf/Config/gcc-ss-linux/include/g++-v3/bits/concept_checks.h: In 
       copy constructor `Y::Y(const Y&)':
    /home/people/wolf/Config/gcc-ss-linux/include/g++-v3/bits/concept_checks.h:530:   instantiated from `static void _Assignable_concept_specification<_Type>::_Assignable_requirement_violation(_Type) [with _Type = Y]'
    /home/people/wolf/Config/gcc-ss-linux/include/g++-v3/bits/stl_map.h:50:   instantiated from `std::map<int, Y, std::less<int>, std::allocator<std::pair<const int, Y> > >'
    ttt.cc:7:   instantiated from here
    /home/people/wolf/Config/gcc-ss-linux/include/g++-v3/bits/concept_checks.h:530: incompatible
       types in assignment of `const int[4]' to `int[4]'
    /home/people/wolf/Config/gcc-ss-linux/include/g++-v3/bits/concept_checks.h: In 
       static member function `static void 
       _Assignable_concept_specification<_Type>::_Assignable_requirement_violation(_Type)
       [with _Type = Y]':
    /home/people/wolf/Config/gcc-ss-linux/include/g++-v3/bits/concept_checks.h:530: 
        initializing argument 1 of `static _Type 
       _STL_ERROR::__assignment_operator_requirement_violation(_Type) [with _Type = 
       Y]'

Note that if I change the type of X::x to
- another type (double, unsigned int, etc), or
- the size of the array to another value than 4,
or
- if I omit the -ggdb flag (!!)
then the compile succeeds. It seems to me that when using
-ggdb, the compiler tries to write out some info on X::x,
finds that Y::y2 has the same type, but somehow scrambles
something in memory.

Regards
  Wolfgang
>How-To-Repeat:

>Fix:

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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]