public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Make cstddef / cstdarg more robust (PR 69881)
@ 2016-02-23  7:15 Bernd Edlinger
  2016-02-23  9:42 ` Jonathan Wakely
  0 siblings, 1 reply; 6+ messages in thread
From: Bernd Edlinger @ 2016-02-23  7:15 UTC (permalink / raw)
  To: gcc-patches, libstdc++; +Cc: Jonathan Wakely

[-- Attachment #1: Type: text/plain, Size: 925 bytes --]

Hi,


as described in the PR 69881 it happens quite often that cstddef is
called with __need_size_t because we still support gmp-4.3.2 which
is installed by contrib/download_prerequisites.  This causes a kind
of undefined behavior.  It is just by chance that this does not cause
the gcc-6 boot-strap to fail, but it causes gcc-4.9 bootstrap to fail
when the gcc-6 version of cstddef is around.  So it looks like a
regression, because the new cstddef is more fragile than before.

As it looks like, neither c/* nor c_std/* headers will compile without
major bug-fixing first, and they are likely not in use by anybody.
Therefore I think it is best not to touch these at all, because it is
hard to test anything there.

So I propose to undefine all problematic __need_* that may cause
cstddef or cstdarg fail to compile.

Boot-strapped and reg-tested on x86_64-pc-linux-gnu
OK for trunk?


Thanks
Bernd.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch-pr69881.diff --]
[-- Type: text/x-patch; name="patch-pr69881.diff", Size: 995 bytes --]

2016-02-23  Bernd Edlinger  <bernd.edlinger@hotmail.de>

	PR libstdc++/69881
	* include/c_global/cstdarg: Undefine __need___va_list.
	* include/c_global/cstddef: Undefine all kinds of __need_*.

Index: libstdc++-v3/include/c_global/cstdarg
===================================================================
--- libstdc++-v3/include/c_global/cstdarg	(revision 233604)
+++ libstdc++-v3/include/c_global/cstdarg	(working copy)
@@ -38,6 +38,7 @@
 
 #pragma GCC system_header
 
+#undef __need___va_list
 #include <bits/c++config.h>
 #include <stdarg.h>
 
Index: libstdc++-v3/include/c_global/cstddef
===================================================================
--- libstdc++-v3/include/c_global/cstddef	(revision 233604)
+++ libstdc++-v3/include/c_global/cstddef	(working copy)
@@ -41,6 +41,11 @@
 
 #pragma GCC system_header
 
+#undef __need_wchar_t
+#undef __need_ptrdiff_t
+#undef __need_size_t
+#undef __need_NULL
+#undef __need_wint_t
 #include <bits/c++config.h>
 #include <stddef.h>
 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Make cstddef / cstdarg more robust (PR 69881)
  2016-02-23  7:15 [PATCH] Make cstddef / cstdarg more robust (PR 69881) Bernd Edlinger
@ 2016-02-23  9:42 ` Jonathan Wakely
  2016-02-23 10:01   ` Bernd Edlinger
  0 siblings, 1 reply; 6+ messages in thread
From: Jonathan Wakely @ 2016-02-23  9:42 UTC (permalink / raw)
  To: Bernd Edlinger; +Cc: gcc-patches, libstdc++

On 23/02/16 07:15 +0000, Bernd Edlinger wrote:
>as described in the PR 69881 it happens quite often that cstddef is
>called with __need_size_t because we still support gmp-4.3.2 which
>is installed by contrib/download_prerequisites.  This causes a kind
>of undefined behavior.  It is just by chance that this does not cause
>the gcc-6 boot-strap to fail, but it causes gcc-4.9 bootstrap to fail
>when the gcc-6 version of cstddef is around.  So it looks like a
>regression, because the new cstddef is more fragile than before.

Is it? cstddef hasn't been changed since 2013-06-11. cstdarg hasn't
been changed since 2011-01-30.

What made them more fragile?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Make cstddef / cstdarg more robust (PR 69881)
  2016-02-23  9:42 ` Jonathan Wakely
@ 2016-02-23 10:01   ` Bernd Edlinger
  2016-02-23 10:09     ` Jakub Jelinek
  2016-02-23 10:16     ` Jonathan Wakely
  0 siblings, 2 replies; 6+ messages in thread
From: Bernd Edlinger @ 2016-02-23 10:01 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: gcc-patches, libstdc++

On 23/02/15 10:42, Jonathan Wakely wrote:
>On 23/02/16 07:15 +0000, Bernd Edlinger wrote:
>>as described in the PR 69881 it happens quite often that cstddef is
>>called with __need_size_t because we still support gmp-4.3.2 which
>>is installed by contrib/download_prerequisites.  This causes a kind
>>of undefined behavior.  It is just by chance that this does not cause
>>the gcc-6 boot-strap to fail, but it causes gcc-4.9 bootstrap to fail
>>when the gcc-6 version of cstddef is around.  So it looks like a
>>regression, because the new cstddef is more fragile than before.
>
>Is it? cstddef hasn't been changed since 2013-06-11. cstdarg hasn't
>been changed since 2011-01-30.
>
>What made them more fragile?

Good question.

The cstddef had this even in gcc.4.9 that's true, but it was not used
by default:

#if __cplusplus >= 201103L
namespace std
{
  // We handle size_t, ptrdiff_t, and nullptr_t in c++config.h.
  using ::max_align_t;
}
#endif


Previously the g++ default was --std=gnu++98,
but gcc-6 changed the default to --std=gnu++14.

And when building gcc-4.9, stage1 does not override that with
--std=gnu++98.

That has changed, and that triggers the latent bug.


Bernd.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Make cstddef / cstdarg more robust (PR 69881)
  2016-02-23 10:01   ` Bernd Edlinger
@ 2016-02-23 10:09     ` Jakub Jelinek
  2016-02-23 10:20       ` Jonathan Wakely
  2016-02-23 10:16     ` Jonathan Wakely
  1 sibling, 1 reply; 6+ messages in thread
From: Jakub Jelinek @ 2016-02-23 10:09 UTC (permalink / raw)
  To: Bernd Edlinger; +Cc: Jonathan Wakely, gcc-patches, libstdc++

On Tue, Feb 23, 2016 at 10:00:58AM +0000, Bernd Edlinger wrote:
> Previously the g++ default was --std=gnu++98,
> but gcc-6 changed the default to --std=gnu++14.
> 
> And when building gcc-4.9, stage1 does not override that with
> --std=gnu++98.
> 
> That has changed, and that triggers the latent bug.

So just use -std=gnu++98 in STAGE1_CXXFLAGS or configure with
CXX='g++ -std=gnu++98' if you try to build gcc-4.9 with gcc 6?

I really don't think we should work around this in GCC 6.

	Jakub

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Make cstddef / cstdarg more robust (PR 69881)
  2016-02-23 10:01   ` Bernd Edlinger
  2016-02-23 10:09     ` Jakub Jelinek
@ 2016-02-23 10:16     ` Jonathan Wakely
  1 sibling, 0 replies; 6+ messages in thread
From: Jonathan Wakely @ 2016-02-23 10:16 UTC (permalink / raw)
  To: Bernd Edlinger; +Cc: gcc-patches, libstdc++

On 23/02/16 10:00 +0000, Bernd Edlinger wrote:
>On 23/02/15 10:42, Jonathan Wakely wrote:
>>On 23/02/16 07:15 +0000, Bernd Edlinger wrote:
>>>as described in the PR 69881 it happens quite often that cstddef is
>>>called with __need_size_t because we still support gmp-4.3.2 which
>>>is installed by contrib/download_prerequisites.  This causes a kind
>>>of undefined behavior.  It is just by chance that this does not cause
>>>the gcc-6 boot-strap to fail, but it causes gcc-4.9 bootstrap to fail
>>>when the gcc-6 version of cstddef is around.  So it looks like a
>>>regression, because the new cstddef is more fragile than before.
>>
>>Is it? cstddef hasn't been changed since 2013-06-11. cstdarg hasn't
>>been changed since 2011-01-30.
>>
>>What made them more fragile?
>
>Good question.
>
>The cstddef had this even in gcc.4.9 that's true, but it was not used
>by default:
>
>#if __cplusplus >= 201103L
>namespace std
>{
>  // We handle size_t, ptrdiff_t, and nullptr_t in c++config.h.
>  using ::max_align_t;
>}
>#endif
>
>
>Previously the g++ default was --std=gnu++98,
>but gcc-6 changed the default to --std=gnu++14.

Ah yes.

>And when building gcc-4.9, stage1 does not override that with
>--std=gnu++98.
>
>That has changed, and that triggers the latent bug.

Alright then, the patch is OK for trunk.

I might revert it once we stop using the buggy GMP in
contrib/download_prerequisites.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Make cstddef / cstdarg more robust (PR 69881)
  2016-02-23 10:09     ` Jakub Jelinek
@ 2016-02-23 10:20       ` Jonathan Wakely
  0 siblings, 0 replies; 6+ messages in thread
From: Jonathan Wakely @ 2016-02-23 10:20 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Bernd Edlinger, gcc-patches, libstdc++

On 23/02/16 11:09 +0100, Jakub Jelinek wrote:
>On Tue, Feb 23, 2016 at 10:00:58AM +0000, Bernd Edlinger wrote:
>> Previously the g++ default was --std=gnu++98,
>> but gcc-6 changed the default to --std=gnu++14.
>>
>> And when building gcc-4.9, stage1 does not override that with
>> --std=gnu++98.
>>
>> That has changed, and that triggers the latent bug.
>
>So just use -std=gnu++98 in STAGE1_CXXFLAGS or configure with
>CXX='g++ -std=gnu++98' if you try to build gcc-4.9 with gcc 6?
>
>I really don't think we should work around this in GCC 6.

I agree, but #undefining those macros doesn't hurt, and hopefully the
issue will go away.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-02-23 10:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-23  7:15 [PATCH] Make cstddef / cstdarg more robust (PR 69881) Bernd Edlinger
2016-02-23  9:42 ` Jonathan Wakely
2016-02-23 10:01   ` Bernd Edlinger
2016-02-23 10:09     ` Jakub Jelinek
2016-02-23 10:20       ` Jonathan Wakely
2016-02-23 10:16     ` Jonathan Wakely

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).