Unreasonable Input in std sort Lambda Expression

	struct Aa
	{
		int i0;
	};
	std::vector<Aa*> list_;
...
	std::sort(list_.begin(), list_.end(), [this, &end_dates](Aa* l, Aa* r) {
		return l->degree_ - r->degree_;
	});

Before the sort, I promise the members of list_ are all not null, but in the sort lambda expression, when running, we will be caught by a null pointer access SIGSEGV, for example, l is null.

Well, the good shot is,

...
	std::sort(list_.begin(), list_.end(), [this, &end_dates](Aa* l, Aa* r) {
		return l->degree_ > r->degree_;
	});

references to including header

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <memory>
unique_ptr
shared_ptr
enable_shared_from_this
 
#include <algorithm>
remove
find
remove_if
find_if
 
#include <sstream>
istringstream
ostringstream
stringstream
 
#include <stdint.h>
int64_t
 
#include <unistd.h>
sleep