For Programmers: Free Programming Magazines  


Home > Archive > VC STL > February 2005 > std::sort strict ordering









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author std::sort strict ordering
Mycroft Holmes

2005-02-14, 9:11 pm

Hi to everyone.

We are trying to port some experimental heavy-computing code from VC7.1
to another platform.
We experienced a problem since we were std::sort'ing a range passing a
non-strict ordering operation (i.e. less_equal instead of less).
VC never complained and produced the right result anyway, while gcc 3.3
crashes (sooner or later it tries to dereference 'end').
What does the standard say? It is undefined behavior?

thanks

--
The set of solutions is never empty.
Two solutions together form a new problem.
-- Mycroft Holmes
Pete Becker

2005-02-14, 9:11 pm

Mycroft Holmes wrote:
> Hi to everyone.
>
> We are trying to port some experimental heavy-computing code from VC7.1
> to another platform.
> We experienced a problem since we were std::sort'ing a range passing a
> non-strict ordering operation (i.e. less_equal instead of less).
> VC never complained and produced the right result anyway, while gcc 3.3
> crashes (sooner or later it tries to dereference 'end').
> What does the standard say? It is undefined behavior?
>


The behavior is undefined.

--

Pete Becker
Dinkumware, Ltd. (http://www.dinkumware.com)
Jerry Coffin

2005-02-14, 9:11 pm

In article <m.holmes-96D7C4.16244508022005@msnews.microsoft.com>,
m.holmes@nospam.it says...

[ ... ]

> We experienced a problem since we were std::sort'ing a range passing a
> non-strict ordering operation (i.e. less_equal instead of less).


You're required to supply a strict weak ordering.

--
Later,
Jerry.

The universe is a figment of its own imagination.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com