This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: [Patch/RFC] Fix libstdc++/9533


Benjamin Kosnik wrote:
> I think it might be best to remove the patch for 6746 entirely, and
> start over.

I think is the only reasonable approach for the 3.3 branch, the
proposed changes to showmanyc seem way too complex to apply this
close to release.

By the way, shouldn't 9533 be changed to high priority? It is a
regression from 3.2.x and IMHO it is a show-stopper.

> My real wish is to separate out the buffered/unbuffered
> classes though, before much more work on this kind of issue happens.

I'm not sure that it is ever correct to use basic_filebuf as a
stream buffer for cin/cout/wcin/wcout etc.

Consider this fragment from 27.3:

  Mixing operations on corresponding wide- and narrow-character
  streams follows the same semantics as mixing such operations
  on FILEs, as specified in Amendment 1 of the ISO C standard.

I read this as meaning that this program:

#include <iostream>
#include <cstdio>
#include <cwchar>

int main()
{
	using namespace std;

	wint_t c1 = wcin.get();
	int c2 = cin.get();

	int n = fwide(stdin, 0);

	fprintf(stderr, "%d %d %d\n", c1, c2, n);

	c1 = wcout.put(L'a') ? L'a' : WEOF;
	c2 = cout.put('b') ? 'b' : EOF;

	n = fwide(stdout, 0);

	wcout.put(L'\n');
	fprintf(stderr, "%d %d %d\n", c1, c2, n);

	return 0;
}

Should have the same output as this program:

#include <cstdio>
#include <cwchar>

int main()
{
	using namespace std;

	wint_t c1 = getwc(stdin);
	int c2 = getc(stdin);

	int n = fwide(stdin, 0);

	fprintf(stderr, "%d %d %d\n", c1, c2, n);

	c1 = putwc(L'a', stdout);
	c2 = putc('b', stdout);

	n = fwide(stdout, 0);

	putwc(L'\n', stdout);
	fprintf(stderr, "%d %d %d\n", c1, c2, n);

	return 0;
}

I don't think that ios_base::sync_with_stdio(false) trumps the above
quote from 27.3, so this program:

#include <iostream>
#include <cstdio>
#include <cwchar>

int main()
{
	using namespace std;

	ios_base::sync_with_stdio(false);

	wint_t c1 = wcin.get();
	int c2 = cin.get();

	int n = fwide(stdin, 0);

	fprintf(stderr, "%d %d %d\n", c1, c2, n);

	c1 = wcout.put(L'a') ? L'a' : WEOF;
	c2 = cout.put('b') ? 'b' : EOF;

	n = fwide(stdout, 0);

	wcout.put(L'\n');
	fprintf(stderr, "%d %d %d\n", c1, c2, n);

	return 0;
}

should probably have the same output as the other two (except that
the return value of fwide may be unspecified).

Regards,
Petur


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]