https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69092

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |4.8.3
            Summary|basic_string constructor    |[4.9/5/6 Regression]
                   |and throwing iterators      |basic_string constructor
                   |                            |and throwing iterators
      Known to fail|                            |4.9.3, 5.3.0, 6.0

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This worked OK in 4.8, and still works OK in C++03 mode (if tweaked to remove
the C++11 features):

#include<string>
#include<iterator>

struct hate_T_iterator : std::iterator<std::forward_iterator_tag, char> {
    explicit hate_T_iterator(char* p) : p(p) {}
    char* p;
    hate_T_iterator& operator++() { ++p; return *this; }
    hate_T_iterator operator++(int) { hate_T_iterator r = *this; ++*this;
return r; }
    char& operator*() const { if(*p == 'T') throw 1; else return *p; }
    char* operator->() const { return p; }
    bool operator== (hate_T_iterator other) const { return p == other.p;}
    bool operator!= (hate_T_iterator other) const { return p != other.p;}
};

int main(){
    char test_str[4] = "ATA";
    try {
        std::string s(hate_T_iterator(test_str), hate_T_iterator(test_str+3));
    }
    catch(...) {
    }
}

Reply via email to