Patchwork C++ PATCH for c++/49673 (constexpr init should go in rodata)

login
register
mail settings
Submitter Jason Merrill
Date July 8, 2011, 5:37 p.m.
Message ID <4E17404C.5080009@redhat.com>
Download mbox | patch
Permalink /patch/103910/
State New
Headers show

Comments

Jason Merrill - July 8, 2011, 5:37 p.m.
On 07/08/2011 10:35 AM, Jakub Jelinek wrote:
> That will match only on ELF and perhaps a few other targets, but I'm certain
> many targets put read-only data elsewhere.  I'd just guard this
> with a few most common target triplets that are known to use .rodata
> section.

Done, thanks.  I've also removed the unneeded check for COMPLETE_TYPE_P.

Tested x86_64-pc-linux-gnu, applying to trunk.
H.J. Lu - July 19, 2012, 2:55 p.m.
On Fri, Jul 8, 2011 at 10:37 AM, Jason Merrill <jason@redhat.com> wrote:
> On 07/08/2011 10:35 AM, Jakub Jelinek wrote:
>>
>> That will match only on ELF and perhaps a few other targets, but I'm
>> certain
>> many targets put read-only data elsewhere.  I'd just guard this
>> with a few most common target triplets that are known to use .rodata
>> section.
>
>
> Done, thanks.  I've also removed the unneeded check for COMPLETE_TYPE_P.
>
>
> Tested x86_64-pc-linux-gnu, applying to trunk.

This caused:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54026

Patch

commit e2f7f86c6d5e734fe393217eaca8d4da9969f343
Author: Jason Merrill <jason@redhat.com>
Date:   Fri Jul 8 10:27:55 2011 -0400

    	* typeck.c (cp_apply_type_quals_to_decl): Don't check
    	COMPLETE_TYPE_P either.

diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index f0d68c3..5febff5 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -8130,12 +8130,10 @@  cp_apply_type_quals_to_decl (int type_quals, tree decl)
   /* We used to check TYPE_NEEDS_CONSTRUCTING here, but now a constexpr
      constructor can produce constant init, so rely on cp_finish_decl to
      clear TREE_READONLY if the variable has non-constant init.  */
-  if (/* If the type isn't complete, we don't know yet if it will need
-	 constructing.  */
-      !COMPLETE_TYPE_P (type)
-      /* If the type has a mutable component, that component might be
-	 modified.  */
-      || TYPE_HAS_MUTABLE_P (type))
+
+  /* If the type has a mutable component, that component might be
+     modified.  */
+  if (TYPE_HAS_MUTABLE_P (type))
     type_quals &= ~TYPE_QUAL_CONST;
 
   c_apply_type_quals_to_decl (type_quals, decl);