Bug 44417 - make check-target-libstdc++-v3 fails due to undefined ptrdiff_t
Summary: make check-target-libstdc++-v3 fails due to undefined ptrdiff_t
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: 4.6.0
Assignee: Paolo Carlini
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-04 13:43 UTC by Johannes Singler
Modified: 2010-06-08 01:49 UTC (History)
4 users (show)

See Also:
Host: x86_64-unknown-linux-gnu
Target: x86_64-unknown-linux-gnu
Build: x86_64-unknown-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2010-06-07 14:02:15


Attachments
Failing test case. (121.18 KB, application/octet-stream)
2010-06-04 18:51 UTC, singler@gcc.gnu.org
Details
Tentative patch (only sanity checked on a system not affected by the glibc issue) (1.13 KB, patch)
2010-06-07 15:17 UTC, Paolo Carlini
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Johannes Singler 2010-06-04 13:43:27 UTC
make check-target-libstdc++-v3 fails because ptrdiff_t is undefined.
std::ptrdiff_t works.
Maybe this bug is related to the Linux system run on.  I have openSuse 11.1 running.

configure --enable-languages=c,c++ --program-suffix=-rep --prefix=$HOME/gcc/install_trunk_1


In file included from /home/singler/gcc/trunk_1/libstdc++-v3/testsuite/util/testsuite_abi.h:27:0,
                 from /home/singler/gcc/trunk_1/libstdc++-v3/testsuite/util/testsuite_abi.cc:23:
/home/singler/gcc/trunk_1/libstdc++-v3/libsupc++/cxxabi.h:371:5: error: 'ptrdiff_t' does not name a type
/home/singler/gcc/trunk_1/libstdc++-v3/libsupc++/cxxabi.h:447:23: error: 'ptrdiff_t' has not been declared
/home/singler/gcc/trunk_1/libstdc++-v3/libsupc++/cxxabi.h:459:18: error: 'ptrdiff_t' has not been declared
/home/singler/gcc/trunk_1/libstdc++-v3/libsupc++/cxxabi.h:469:26: error: 'ptrdiff_t' has not been declared
/home/singler/gcc/trunk_1/libstdc++-v3/libsupc++/cxxabi.h:495:18: error: 'ptrdiff_t' has not been declared
/home/singler/gcc/trunk_1/libstdc++-v3/libsupc++/cxxabi.h:501:26: error: 'ptrdiff_t' has not been declared
/home/singler/gcc/trunk_1/libstdc++-v3/libsupc++/cxxabi.h:540:18: error: 'ptrdiff_t' has not been declared
/home/singler/gcc/trunk_1/libstdc++-v3/libsupc++/cxxabi.h:546:26: error: 'ptrdiff_t' has not been declared
/home/singler/gcc/trunk_1/libstdc++-v3/libsupc++/cxxabi.h:566:4: error: 'ptrdiff_t' has not been declared
compiler exited with status 1

Any ideas and/or a workaround?
Comment 1 Paolo Carlini 2010-06-04 13:49:56 UTC
I can't reproduce this. I booted and tested many times on various linux systems and HJ already reported many succesfull testresults since. Please remove everything from the build dir, gave everything fresh and retry.
Comment 2 Johannes Singler 2010-06-04 14:16:56 UTC
I had cleaned the builddir already.
Adding 

#include <cstddef> 

solves the problem. 
The crucial file seems to be

lib/gcc/x86_64-unknown-linux-gnu/4.6.0/include/stddef.h

Only if it is (indirectly) included, ptrdiff_t is defined in the global scope.  Maybe on other systems, ptrdiff_t is also declared somewhere else, so the problem does not appear.
Comment 3 Johannes Singler 2010-06-04 14:19:22 UTC
*** Bug 44416 has been marked as a duplicate of this bug. ***
Comment 4 Paolo Carlini 2010-06-04 14:23:49 UTC
To be clear: does a normal 'make check' (either from the root of the build dir or from inside the library build dir) work? Because it works here and fo everybody else on the testresult mailing list, also for people using your exact same linux.
Comment 5 Paolo Carlini 2010-06-04 14:28:14 UTC
Hey, 44416 is *not* a duplicate! Please re-open it immediately.
Comment 6 Paolo Carlini 2010-06-04 14:52:03 UTC
Note that cxxabi.h already includes <stddef.h> and at that line 371 uses ptrdiff_t unqualified, thus everything is fine. I suspect you simply forgot to update your compiler, because the current library does not work without a recent front end fix applied by Jason.
Comment 7 Paolo Carlini 2010-06-04 14:55:02 UTC
Closing.
Comment 8 singler@gcc.gnu.org 2010-06-04 18:51:08 UTC
I can't help it, "make check" in the libstdc++-v3 directory still does not work for me, even after reconfiguring and recompiling everything from scratch, using vanilla rev 160275.
Let's have a look at attached testsuite_abi.ii.
The first typedef for std::ptrdiff_t is in line 49, but the first typedef for ptrdiff_t in the global scope is only in line 30203.
The first error is in line 24823, however, this is in (sub?) namespace __cxxabiv1.
Should this work anyway?
I'm quite lost.
Comment 9 singler@gcc.gnu.org 2010-06-04 18:51:53 UTC
Created attachment 20845 [details]
Failing test case.
Comment 10 Paolo Carlini 2010-06-04 18:55:52 UTC
Something is broken in your system, I also tested on an Open Suse 11.1, to be sure, and everything works fine. Remove everything, fetch again the entire gcc mainline and try again.
Comment 11 Johannes Singler 2010-06-07 09:35:29 UTC
Obviously, I'm not the only one having this problem, Jason has patched libstdc++-v3/testsuite/util/testsuite_abi.h in the meantime.

------------------------------------------------------------------------
r160313 | jason | 2010-06-05 15:13:46 +0200 (Sat, 05 Jun 2010) | 1 line

        * testsuite/util/testsuite_abi.h: Work around glibc BZ 9694.

+// Include stddef now to work around glibc BZ 9694
+#include <stddef.h>

related to

<http://sourceware.org/bugzilla/show_bug.cgi?id=9694>

This solves the problem testsuite_abi.h, but then, the next test fails, namely testsuite_allocator.h.

I have tested all that using a different user ID, with a completely clean environment and new checkout, but the problem persists.
Comment 12 Paolo Carlini 2010-06-07 10:09:26 UTC
Yes, it's a glibc bug (I don't have available any machine using that old glibc), and if you look at the mailing list, I already commented that could be related to your issue. I think we should use the same workaround for that other testsuite header and closw this sucker. Any patch along these lines is pre-approved, in any case I would not be able to test it.
Comment 13 Paolo Carlini 2010-06-07 10:18:10 UTC
As a matter of fact, in testsuite_allocator.h the problem can be solved much more cleanly by simply qualifying with std:: the size_t and ptrdiff_t in tge second half of the file, I can do that later today. 
Comment 14 Paolo Carlini 2010-06-07 15:17:47 UTC
Created attachment 20855 [details]
Tentative patch (only sanity checked on a system not affected by the glibc issue)
Comment 15 Paolo Carlini 2010-06-07 15:23:25 UTC
Johannes, can you try the patch and in case, give me some details about the remaining issues? The idea is simply that if a glibc header has been included by <cwctype> before <wctype.h>, then __GLIBC__ is defined and __GLIBC_MINOR__ set to the proper value. If the minor is < 10, thus <wctype.h> is buggy, we include by hand <stddef.h> *before* <wctype.h>. It should work. Unless the library is somehow including <wctype.h> somewhere else outside <cwctype>. That should be also fixed.
Comment 16 Paolo Carlini 2010-06-07 15:27:05 UTC
Errata: "... by <cwctype> before <wctype.h>..." should read "... before <cwctype> wants to include <wctype.h>..."
Comment 17 paolo@gcc.gnu.org 2010-06-08 01:46:28 UTC
Subject: Bug 44417

Author: paolo
Date: Tue Jun  8 01:46:10 2010
New Revision: 160417

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=160417
Log:
2010-06-07  Paolo Carlini  <paolo.carlini@oracle.com>

	PR libstdc++/44417
	* include/c_std/cwctype: Provide a workaround for bug glibc
	BZ 9694 affecting glibc 2.9 and older.
	* include/c_global/cwctype: Likewise.
	* testsuite/util/testsuite_abi.h: Remove temporary workaround.
	* testsuite/util/testsuite_allocator.h: Use everywhere std::size_t
	and std::ptrdiff_t, don't include <cstddef>.

	* testsuite/27_io/basic_ostream/inserters_other/wchar_t/
	error_code.cc: Minor tweak, prefer <cwchar> to <wchar.h>.

Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/include/c_global/cwctype
    trunk/libstdc++-v3/include/c_std/cwctype
    trunk/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/error_code.cc
    trunk/libstdc++-v3/testsuite/util/testsuite_abi.h
    trunk/libstdc++-v3/testsuite/util/testsuite_allocator.h

Comment 18 Paolo Carlini 2010-06-08 01:49:33 UTC
Fixed.
Comment 19 Paolo Carlini 2010-06-08 01:49:54 UTC
Yes.