cppfront
cppfront copied to clipboard
[BUG] does not bounds check iterators
the following code segfaults:
using while first <= last {
instead of while first < last {
To Reproduce 1.
main: () -> int
= {
words: std::vector<std::string> = ( "decorated", "hello", "world" );
first: std::vector<std::string>::iterator = words.begin();
last : std::vector<std::string>::iterator = words.end();
while first <= last {
print_and_decorate(first*);
first++;
}
}
print_and_decorate: (thing:_) =
std::cout << ">> " << thing << "\n";
$ cppfront pure2-bounds-safety-iterator.cpp2 -p -s
pure2-bounds-safety-iterator.cpp2... ok (all Cpp2, passes safety checks)
$ g++ -std=c++20 pure2-bounds-safety-iterator.cpp -o pure2-bounds-safety-iterator
$ ./pure2-bounds-safety-iterator
>> decorated
>> hello
>> world
Segmentation fault (core dumped)
-
I wanted cppfront to reject it
-
it it passed and segfaulted on running