public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: val@digiways.com
To: gcc-gnats@gcc.gnu.org
Cc: scmvs@cs.cf.ac.uk
Subject: libstdc++/9444: g++ STL requires iterators passed to string constructor to have a constructor without parameters, but C++ standard does not require that
Date: Sun, 26 Jan 2003 22:56:00 -0000	[thread overview]
Message-ID: <20030126225244.32223.qmail@sources.redhat.com> (raw)


>Number:         9444
>Category:       libstdc++
>Synopsis:       g++ STL requires iterators passed to string constructor to have a constructor without parameters, but C++ standard does not require that
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Sun Jan 26 22:56:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Val Samko
>Release:        gcc version 3.2 (mingw special 20020817-1)
>Organization:
>Environment:
Win2K
>Description:
The following 100% ANSI C++ compliant code does not compile with g++, unless we add "it(){}" to "it" struct.
That is because of the following lines in  include\c++\3.2\bits\basic_string.tcc
-------------------
	// NB: Not required, but considered best practice.
	if (__builtin_expect(__beg == _InIter(), 0))
	  __throw_logic_error("attempt to create string with null pointer");
-------------------
note that `_InIter()` there, which requires iterator to have
a parameterless constructor.

===========================
#include <string>
#include <vector>
using namespace std;

struct it : public std::iterator<std::forward_iterator_tag, string::value_type>
{
	it(string::iterator i_) : i(i_) {}
	char& operator *() { return *i; }
	bool operator == (const it& i_) { return i == i_.i; }
	bool operator != (const it& i_) { return i != i_.i; }
	it& operator ++ () { ++i; return *this; }
	string::iterator i;
};

template<class Cont, class It>
	void foo(Cont& c, It f, It l) { typedef typename Cont::value_type vt; c.push_back(vt(f, l)); }
int main()
{
	string s1 = "querty";
	vector<string> s2;
	foo(s2, it(s1.begin()), it(s1.end()));
	return 1;
}
>How-To-Repeat:

>Fix:
Remove offending lines from 
include\c++\3.2\bits\basic_string.tcc
>Release-Note:
>Audit-Trail:
>Unformatted:


             reply	other threads:[~2003-01-26 22:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-01-26 22:56 val [this message]
2003-01-26 23:31 paolo
2003-01-30  9:44 paolo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030126225244.32223.qmail@sources.redhat.com \
    --to=val@digiways.com \
    --cc=gcc-gnats@gcc.gnu.org \
    --cc=scmvs@cs.cf.ac.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).