public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/37721]  New: Segmentation fault
@ 2008-10-02 19:17 ivranos at freemail dot gr
  2008-10-02 19:18 ` [Bug c++/37721] " ivranos at freemail dot gr
                   ` (20 more replies)
  0 siblings, 21 replies; 23+ messages in thread
From: ivranos at freemail dot gr @ 2008-10-02 19:17 UTC (permalink / raw)
  To: gcc-bugs

The following code gives segmentation fault:


#include <iostream>
#include <ctime>
#include <vector>
#include <list>
#include <cstddef>
#include <algorithm>


class SomeClass
{
    public:
    typedef std::vector<int> TypeVector;

    TypeVector vec;

    enum { VectorSize= 100 };

    public:

    SomeClass();
    SomeClass(const SomeClass &);

    bool operator<(const SomeClass &argSomeClass) const
    {
        return vec[0]< argSomeClass.vec[0];
    }
};





int main()
{
    using namespace std;

    srand(time(0));

    const size_t SIZE=1000;

    typedef vector<SomeClass> Vector;
    typedef list<SomeClass> List;


    cout<< "\nCreating vector with "<< SIZE<< " elements..."<< flush;
    Vector vec(SIZE);

    cout<<"   Done!\n\n"<< flush;

    List lis;


    cout<< "Filling list with vector elements..."<< flush;

    for(Vector::size_type i= 0; i< vec.size(); ++i)
        lis.push_back(vec[i]);

    cout<< "   Done!\n\n"<< flush;


    clock_t timeBeginVector, timeEndVector, timeBeginList, timeEndList;


    cout<< "Timing the sorting of the vector..."<< flush;


    // Diagnostic code line. Should output 1000 and 100 
    // cout<< endl<< vec.size()<< endl<< vec[0].vec.size()<< endl;

    timeBeginVector= clock();

    sort(vec.begin(), vec.end());

    timeEndVector= clock();

    cout<< "   Done!\n\n"<< flush;


    cout<< "Timing the sorting of the list..."<< flush;

    timeBeginList= clock();

    lis.sort();

    timeEndList= clock();


    cout<< "   Done!\n\n"<< flush;


    cout<< "The sorting of the vector took "
        <<  static_cast<double>((timeEndVector- timeBeginVector))/
CLOCKS_PER_SEC
        << " seconds\n\n";

    cout<< "The sorting of the list took "
        << static_cast<double>((timeEndList- timeBeginList))/ CLOCKS_PER_SEC
        << " seconds\n\n";
}



SomeClass::SomeClass():vec(VectorSize)
{
    using namespace std;

    for(TypeVector::size_type i= 0; i< vec.size(); ++i)
        vec[i]= rand();

    sort(vec.begin(), vec.end());
}


SomeClass::SomeClass(const SomeClass &):vec(VectorSize)
{
    using namespace std;

    for(TypeVector::size_type i= 0; i< vec.size(); ++i)
        vec[i]= rand();

    sort(vec.begin(), vec.end());
}


-- 
           Summary: Segmentation fault
           Product: gcc
           Version: 4.2.3
            Status: UNCONFIRMED
          Severity: blocker
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ivranos at freemail dot gr
  GCC host triplet: Ubuntu 8.04 x86
GCC target triplet: Ubuntu 8.04 x86


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


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

* [Bug c++/37721] Segmentation fault
  2008-10-02 19:17 [Bug c++/37721] New: Segmentation fault ivranos at freemail dot gr
@ 2008-10-02 19:18 ` ivranos at freemail dot gr
  2008-10-02 19:20 ` pinskia at gcc dot gnu dot org
                   ` (19 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: ivranos at freemail dot gr @ 2008-10-02 19:18 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from ivranos at freemail dot gr  2008-10-02 19:17 -------
Created an attachment (id=16454)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=16454&action=view)
The produced .ii file

This is the produced main.ii file created by

g++ -ansi -pedantic-errors -Wall -save-temps main.cc -o foobar_cpp 


-- 


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


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

* [Bug c++/37721] Segmentation fault
  2008-10-02 19:17 [Bug c++/37721] New: Segmentation fault ivranos at freemail dot gr
  2008-10-02 19:18 ` [Bug c++/37721] " ivranos at freemail dot gr
@ 2008-10-02 19:20 ` pinskia at gcc dot gnu dot org
  2008-10-02 19:29 ` [Bug libstdc++/37721] " ivranos at freemail dot gr
                   ` (18 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-10-02 19:20 UTC (permalink / raw)
  To: gcc-bugs



-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pinskia at gcc dot gnu dot
                   |                            |org
           Severity|blocker                     |normal


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


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

* [Bug libstdc++/37721] Segmentation fault
  2008-10-02 19:17 [Bug c++/37721] New: Segmentation fault ivranos at freemail dot gr
  2008-10-02 19:18 ` [Bug c++/37721] " ivranos at freemail dot gr
  2008-10-02 19:20 ` pinskia at gcc dot gnu dot org
@ 2008-10-02 19:29 ` ivranos at freemail dot gr
  2008-10-02 20:43 ` paolo dot carlini at oracle dot com
                   ` (17 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: ivranos at freemail dot gr @ 2008-10-02 19:29 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from ivranos at freemail dot gr  2008-10-02 19:27 -------
Created an attachment (id=16455)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=16455&action=view)
The produced main.ii file

The produced main.ii file by

g++ -ansi -pedantic-errors -Wall -save-temps main.cc -o foobar_cpp 


-- 


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


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

* [Bug libstdc++/37721] Segmentation fault
  2008-10-02 19:17 [Bug c++/37721] New: Segmentation fault ivranos at freemail dot gr
                   ` (2 preceding siblings ...)
  2008-10-02 19:29 ` [Bug libstdc++/37721] " ivranos at freemail dot gr
@ 2008-10-02 20:43 ` paolo dot carlini at oracle dot com
  2008-10-02 21:11 ` ivranos at freemail dot gr
                   ` (16 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: paolo dot carlini at oracle dot com @ 2008-10-02 20:43 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from paolo dot carlini at oracle dot com  2008-10-02 20:42 -------
Building with -D_GLIBCXX_DEBUG reveals immediately at run-time that the code is
invalid.


-- 

paolo dot carlini at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


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


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

* [Bug libstdc++/37721] Segmentation fault
  2008-10-02 19:17 [Bug c++/37721] New: Segmentation fault ivranos at freemail dot gr
                   ` (3 preceding siblings ...)
  2008-10-02 20:43 ` paolo dot carlini at oracle dot com
@ 2008-10-02 21:11 ` ivranos at freemail dot gr
  2008-10-02 22:19 ` paolo dot carlini at oracle dot com
                   ` (15 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: ivranos at freemail dot gr @ 2008-10-02 21:11 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from ivranos at freemail dot gr  2008-10-02 21:09 -------
May you be more specific and tell what exactly is invalid? That is what is the
error in the source code.


-- 

ivranos at freemail dot gr changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|INVALID                     |


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


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

* [Bug libstdc++/37721] Segmentation fault
  2008-10-02 19:17 [Bug c++/37721] New: Segmentation fault ivranos at freemail dot gr
                   ` (4 preceding siblings ...)
  2008-10-02 21:11 ` ivranos at freemail dot gr
@ 2008-10-02 22:19 ` paolo dot carlini at oracle dot com
  2008-10-02 23:35 ` ivranos at freemail dot gr
                   ` (14 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: paolo dot carlini at oracle dot com @ 2008-10-02 22:19 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from paolo dot carlini at oracle dot com  2008-10-02 22:18 -------
Why should I do this work for you? This is not an help line, the only purpose
of Bugzilla is tracking and fixing bugs, I'm maintaining the library and given
the diagnostic provided by debug-mode (which exists for a reason) I'm sure this
is user-code error.


-- 

paolo dot carlini at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


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


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

* [Bug libstdc++/37721] Segmentation fault
  2008-10-02 19:17 [Bug c++/37721] New: Segmentation fault ivranos at freemail dot gr
                   ` (5 preceding siblings ...)
  2008-10-02 22:19 ` paolo dot carlini at oracle dot com
@ 2008-10-02 23:35 ` ivranos at freemail dot gr
  2008-10-02 23:38 ` ivranos at freemail dot gr
                   ` (13 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: ivranos at freemail dot gr @ 2008-10-02 23:35 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from ivranos at freemail dot gr  2008-10-02 23:34 -------
The bug can easily be in the library.


-- 

ivranos at freemail dot gr changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|INVALID                     |


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


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

* [Bug libstdc++/37721] Segmentation fault
  2008-10-02 19:17 [Bug c++/37721] New: Segmentation fault ivranos at freemail dot gr
                   ` (6 preceding siblings ...)
  2008-10-02 23:35 ` ivranos at freemail dot gr
@ 2008-10-02 23:38 ` ivranos at freemail dot gr
  2008-10-03  0:10 ` pinskia at gcc dot gnu dot org
                   ` (12 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: ivranos at freemail dot gr @ 2008-10-02 23:38 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from ivranos at freemail dot gr  2008-10-02 23:37 -------
To be more precise: I believe the bug is in the library.


-- 


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


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

* [Bug libstdc++/37721] Segmentation fault
  2008-10-02 19:17 [Bug c++/37721] New: Segmentation fault ivranos at freemail dot gr
                   ` (7 preceding siblings ...)
  2008-10-02 23:38 ` ivranos at freemail dot gr
@ 2008-10-03  0:10 ` pinskia at gcc dot gnu dot org
  2008-10-03  8:40 ` [Bug c++/37721] " ivranos at freemail dot gr
                   ` (11 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-10-03  0:10 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from pinskia at gcc dot gnu dot org  2008-10-03 00:09 -------
Nope, your copy constructor causes the crash.  It is not really doing a copy of
the struct but causing a random placement to happen so operator< will return
different result when we do a copy between values and such.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


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


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

* [Bug c++/37721] Segmentation fault
  2008-10-02 19:17 [Bug c++/37721] New: Segmentation fault ivranos at freemail dot gr
                   ` (8 preceding siblings ...)
  2008-10-03  0:10 ` pinskia at gcc dot gnu dot org
@ 2008-10-03  8:40 ` ivranos at freemail dot gr
  2008-10-03 17:34   ` Andrew Thomas Pinski
  2008-10-03  8:42 ` [Bug libstdc++/37721] " paolo dot carlini at oracle dot com
                   ` (10 subsequent siblings)
  20 siblings, 1 reply; 23+ messages in thread
From: ivranos at freemail dot gr @ 2008-10-03  8:40 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from ivranos at freemail dot gr  2008-10-03 08:38 -------
I am sorry but you are not right/specific.

At first there is no struct in the code, only class. Second, the copy
constructor does not copy the passed argument, it ignores it. But it
initialises its data member the same way as the main constructor.

So, there isn't any bug.


-- 

ivranos at freemail dot gr changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
          Component|libstdc++                   |c++
         Resolution|INVALID                     |


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


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

* [Bug libstdc++/37721] Segmentation fault
  2008-10-02 19:17 [Bug c++/37721] New: Segmentation fault ivranos at freemail dot gr
                   ` (9 preceding siblings ...)
  2008-10-03  8:40 ` [Bug c++/37721] " ivranos at freemail dot gr
@ 2008-10-03  8:42 ` paolo dot carlini at oracle dot com
  2008-10-03  8:49 ` ivranos at freemail dot gr
                   ` (9 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: paolo dot carlini at oracle dot com @ 2008-10-03  8:42 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from paolo dot carlini at oracle dot com  2008-10-03 08:41 -------
To be clear: in general PRs are not meant to be re-opened by submitter at will,
unless he provides at the same time additional, detailed evidence going beyond
the initial report. Debug-mode cannot be wrong. Please spend your time on
something else. 


-- 

paolo dot carlini at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
          Component|c++                         |libstdc++
         Resolution|                            |INVALID


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


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

* [Bug libstdc++/37721] Segmentation fault
  2008-10-02 19:17 [Bug c++/37721] New: Segmentation fault ivranos at freemail dot gr
                   ` (10 preceding siblings ...)
  2008-10-03  8:42 ` [Bug libstdc++/37721] " paolo dot carlini at oracle dot com
@ 2008-10-03  8:49 ` ivranos at freemail dot gr
  2008-10-03  8:53 ` paolo dot carlini at oracle dot com
                   ` (8 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: ivranos at freemail dot gr @ 2008-10-03  8:49 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from ivranos at freemail dot gr  2008-10-03 08:48 -------
I posted the code to c.l.c++ with the subject "Segmentation fault". If noone
finds any bug, I will reopen the bug here.


-- 


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


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

* [Bug libstdc++/37721] Segmentation fault
  2008-10-02 19:17 [Bug c++/37721] New: Segmentation fault ivranos at freemail dot gr
                   ` (11 preceding siblings ...)
  2008-10-03  8:49 ` ivranos at freemail dot gr
@ 2008-10-03  8:53 ` paolo dot carlini at oracle dot com
  2008-10-03  9:10 ` ivranos at freemail dot gr
                   ` (7 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: paolo dot carlini at oracle dot com @ 2008-10-03  8:53 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #12 from paolo dot carlini at oracle dot com  2008-10-03 08:52 -------
Good. In general, please don't try to force the GCC maintainers to debug user
code, this is not going to work. And, by the way, Andrew is right, your class
SomeClass appears badly broken in many different ways.


-- 


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


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

* [Bug libstdc++/37721] Segmentation fault
  2008-10-02 19:17 [Bug c++/37721] New: Segmentation fault ivranos at freemail dot gr
                   ` (12 preceding siblings ...)
  2008-10-03  8:53 ` paolo dot carlini at oracle dot com
@ 2008-10-03  9:10 ` ivranos at freemail dot gr
  2008-10-03  9:22 ` paolo dot carlini at oracle dot com
                   ` (6 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: ivranos at freemail dot gr @ 2008-10-03  9:10 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #13 from ivranos at freemail dot gr  2008-10-03 09:09 -------
The prurpose of the code is to benchmark the sorting of a vector and of a list
with complex objects as their elements (SomeClass).

SomeClass itself doesn't make any other sense, its purpose is to be complex.

I think there is no source code bug on it, that accesses inaccessible memory.

Noone here spotted such a bug, noone in c.l.c++ spotted a bug too, since I had
posted the code there previously.

But in any case, I posted the code in a new thread with subject "Segmentation
fault".

If noone finds any source code bug, I will reopen the GCC bug report here.


-- 


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


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

* [Bug libstdc++/37721] Segmentation fault
  2008-10-02 19:17 [Bug c++/37721] New: Segmentation fault ivranos at freemail dot gr
                   ` (13 preceding siblings ...)
  2008-10-03  9:10 ` ivranos at freemail dot gr
@ 2008-10-03  9:22 ` paolo dot carlini at oracle dot com
  2008-10-03  9:55 ` ivranos at freemail dot gr
                   ` (5 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: paolo dot carlini at oracle dot com @ 2008-10-03  9:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #14 from paolo dot carlini at oracle dot com  2008-10-03 09:20 -------
You can re-open it, unfortunately we cannot avoid it, at the moment, but given
that you are doing it against the judgement of the maintainers, nobody will pay
any further attention to it, ever. Be warned.


-- 


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


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

* [Bug libstdc++/37721] Segmentation fault
  2008-10-02 19:17 [Bug c++/37721] New: Segmentation fault ivranos at freemail dot gr
                   ` (14 preceding siblings ...)
  2008-10-03  9:22 ` paolo dot carlini at oracle dot com
@ 2008-10-03  9:55 ` ivranos at freemail dot gr
  2008-10-03 11:53 ` ivranos at freemail dot gr
                   ` (4 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: ivranos at freemail dot gr @ 2008-10-03  9:55 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #15 from ivranos at freemail dot gr  2008-10-03 09:54 -------
So, if there isn't any source code bug at my side, and it is a compiler bug,
you mean "the maintainers" don't care to fix it?


-- 


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


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

* [Bug libstdc++/37721] Segmentation fault
  2008-10-02 19:17 [Bug c++/37721] New: Segmentation fault ivranos at freemail dot gr
                   ` (15 preceding siblings ...)
  2008-10-03  9:55 ` ivranos at freemail dot gr
@ 2008-10-03 11:53 ` ivranos at freemail dot gr
  2008-10-03 11:56 ` ivranos at freemail dot gr
                   ` (3 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: ivranos at freemail dot gr @ 2008-10-03 11:53 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #16 from ivranos at freemail dot gr  2008-10-03 11:52 -------
I managed to replicate the bug in simple code:


#include <iostream>
#include <ctime>
#include <cstdlib>
#include <vector>


int main()
{
    using namespace std;

    vector<int> intVector(1000*1000);

    srand(time(0));


    for(size_t i= 0; i< RAND_MAX; ++i)
    {
        for (vector<int>::size_type j= 0; i< intVector.size(); ++j)
            intVector[j]= rand();

        sort(intVector.begin(), intVector.end());
    }
}


-- 

ivranos at freemail dot gr changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|INVALID                     |


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


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

* [Bug libstdc++/37721] Segmentation fault
  2008-10-02 19:17 [Bug c++/37721] New: Segmentation fault ivranos at freemail dot gr
                   ` (16 preceding siblings ...)
  2008-10-03 11:53 ` ivranos at freemail dot gr
@ 2008-10-03 11:56 ` ivranos at freemail dot gr
  2008-10-03 12:00 ` ivranos at freemail dot gr
                   ` (2 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: ivranos at freemail dot gr @ 2008-10-03 11:56 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #17 from ivranos at freemail dot gr  2008-10-03 11:55 -------
The bug occurs in this simpler code too:


#include <iostream>
#include <ctime>
#include <cstdlib>
#include <vector>
#include <limits>


int main()
{
    using namespace std;

    vector<int> intVector(1000*1000);

    srand(time(0));


    for(size_t i= 0; i< numeric_limits<size_t>::max()/2; ++i)
    {
        for (vector<int>::size_type j= 0; i< intVector.size(); ++j)
            intVector[j]= rand();
    }
}


-- 


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


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

* [Bug libstdc++/37721] Segmentation fault
  2008-10-02 19:17 [Bug c++/37721] New: Segmentation fault ivranos at freemail dot gr
                   ` (17 preceding siblings ...)
  2008-10-03 11:56 ` ivranos at freemail dot gr
@ 2008-10-03 12:00 ` ivranos at freemail dot gr
  2008-10-03 13:22 ` paolo dot carlini at oracle dot com
  2008-10-03 17:35 ` pinskia at gmail dot com
  20 siblings, 0 replies; 23+ messages in thread
From: ivranos at freemail dot gr @ 2008-10-03 12:00 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #18 from ivranos at freemail dot gr  2008-10-03 11:59 -------
The last two code snippers had errors.


-- 

ivranos at freemail dot gr changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


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


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

* [Bug libstdc++/37721] Segmentation fault
  2008-10-02 19:17 [Bug c++/37721] New: Segmentation fault ivranos at freemail dot gr
                   ` (18 preceding siblings ...)
  2008-10-03 12:00 ` ivranos at freemail dot gr
@ 2008-10-03 13:22 ` paolo dot carlini at oracle dot com
  2008-10-03 17:35 ` pinskia at gmail dot com
  20 siblings, 0 replies; 23+ messages in thread
From: paolo dot carlini at oracle dot com @ 2008-10-03 13:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #19 from paolo dot carlini at oracle dot com  2008-10-03 13:21 -------
Before anything else, you should realize that, per 23.1/3, the type of objects
stored in a std::vector must meet the requirements of CopyConstructible types
(20.1.3), which, in turn, include semantic requirements: the copy constructor
of SomeClass doesn't meet the requirements in Table 30, in short does not
really copy construct.


-- 


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


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

* Re: [Bug c++/37721] Segmentation fault
  2008-10-03  8:40 ` [Bug c++/37721] " ivranos at freemail dot gr
@ 2008-10-03 17:34   ` Andrew Thomas Pinski
  0 siblings, 0 replies; 23+ messages in thread
From: Andrew Thomas Pinski @ 2008-10-03 17:34 UTC (permalink / raw)
  To: gcc-bugzilla; +Cc: gcc-bugs



Sent from my iPhone

On Oct 3, 2008, at 1:38 AM, "ivranos at freemail dot gr" <gcc-bugzilla@gcc.gnu.org 
 > wrote:

>
>
> ------- Comment #9 from ivranos at freemail dot gr  2008-10-03 08:38  
> -------
> I am sorry but you are not right/specific.
>
> At first there is no struct in the code, only class.

In C++ structs/classes are the same thing except if it is private or  
public by defaut.

> Second, the copy
> constructor does not copy the passed argument, it ignores it.

And that is the bug really. Sort uses the copy construct to swap two  
elements of the vector. So you will generate random data again and  
again and the sort becomes confused.

Note std::sort uses std::swap which is defined this way.

Sorry but there is no bug in the library or GCC.

> But it
> initialises its data member the same way as the main constructor.
>
> So, there isn't any bug.
>
>
> -- 
>
> ivranos at freemail dot gr changed:
>
>           What    |Removed                     |Added
> --- 
> --- 
> ----------------------------------------------------------------------
>             Status|RESOLVED                    |UNCONFIRMED
>          Component|libstdc++                   |c++
>         Resolution|INVALID                     |
>
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37721
>


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

* [Bug libstdc++/37721] Segmentation fault
  2008-10-02 19:17 [Bug c++/37721] New: Segmentation fault ivranos at freemail dot gr
                   ` (19 preceding siblings ...)
  2008-10-03 13:22 ` paolo dot carlini at oracle dot com
@ 2008-10-03 17:35 ` pinskia at gmail dot com
  20 siblings, 0 replies; 23+ messages in thread
From: pinskia at gmail dot com @ 2008-10-03 17:35 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #20 from pinskia at gmail dot com  2008-10-03 17:34 -------
Subject: Re:  Segmentation fault



Sent from my iPhone

On Oct 3, 2008, at 1:38 AM, "ivranos at freemail dot gr"
<gcc-bugzilla@gcc.gnu.org 
 > wrote:

>
>
> ------- Comment #9 from ivranos at freemail dot gr  2008-10-03 08:38  
> -------
> I am sorry but you are not right/specific.
>
> At first there is no struct in the code, only class.

In C++ structs/classes are the same thing except if it is private or  
public by defaut.

> Second, the copy
> constructor does not copy the passed argument, it ignores it.

And that is the bug really. Sort uses the copy construct to swap two  
elements of the vector. So you will generate random data again and  
again and the sort becomes confused.

Note std::sort uses std::swap which is defined this way.

Sorry but there is no bug in the library or GCC.

> But it
> initialises its data member the same way as the main constructor.
>
> So, there isn't any bug.
>
>
> -- 
>
> ivranos at freemail dot gr changed:
>
>           What    |Removed                     |Added
> --- 
> --- 
> ----------------------------------------------------------------------
>             Status|RESOLVED                    |UNCONFIRMED
>          Component|libstdc++                   |c++
>         Resolution|INVALID                     |
>
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37721
>


-- 


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


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

end of thread, other threads:[~2008-10-03 17:35 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-02 19:17 [Bug c++/37721] New: Segmentation fault ivranos at freemail dot gr
2008-10-02 19:18 ` [Bug c++/37721] " ivranos at freemail dot gr
2008-10-02 19:20 ` pinskia at gcc dot gnu dot org
2008-10-02 19:29 ` [Bug libstdc++/37721] " ivranos at freemail dot gr
2008-10-02 20:43 ` paolo dot carlini at oracle dot com
2008-10-02 21:11 ` ivranos at freemail dot gr
2008-10-02 22:19 ` paolo dot carlini at oracle dot com
2008-10-02 23:35 ` ivranos at freemail dot gr
2008-10-02 23:38 ` ivranos at freemail dot gr
2008-10-03  0:10 ` pinskia at gcc dot gnu dot org
2008-10-03  8:40 ` [Bug c++/37721] " ivranos at freemail dot gr
2008-10-03 17:34   ` Andrew Thomas Pinski
2008-10-03  8:42 ` [Bug libstdc++/37721] " paolo dot carlini at oracle dot com
2008-10-03  8:49 ` ivranos at freemail dot gr
2008-10-03  8:53 ` paolo dot carlini at oracle dot com
2008-10-03  9:10 ` ivranos at freemail dot gr
2008-10-03  9:22 ` paolo dot carlini at oracle dot com
2008-10-03  9:55 ` ivranos at freemail dot gr
2008-10-03 11:53 ` ivranos at freemail dot gr
2008-10-03 11:56 ` ivranos at freemail dot gr
2008-10-03 12:00 ` ivranos at freemail dot gr
2008-10-03 13:22 ` paolo dot carlini at oracle dot com
2008-10-03 17:35 ` pinskia at gmail dot com

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