This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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: RFA: PATCH to initializer_constant_valid_p for c++/38880


On Mon, Feb 23, 2009 at 1:05 PM, Jason Merrill <jason@redhat.com> wrote:
> Ian Lance Taylor wrote:
>>
>> Use a cast. ?The initializer_constant_valid_p code will look through
>> casts.
>
> Good point, with a cast I was able to make it do odd things. ?Fixed thus,
> and regression tested x86_64-pc-linux-gnu. ?OK for trunk?
>
>

bash-3.2$ cat g++.dg/init/static-init1.C
// Related to the patch for 38880.
// Make sure we don't think we can initialize a at compile time.

char c;
short a[] = { (short)((int)&c + (int)&c) };
bash-3.2$

Doesn't work on Linux/x86-64.  I think this patch:

Index: g++.dg/init/static-init1.C
===================================================================
--- g++.dg/init/static-init1.C	(revision 144401)
+++ g++.dg/init/static-init1.C	(working copy)
@@ -2,4 +2,4 @@
 // Make sure we don't think we can initialize a at compile time.

 char c;
-short a[] = { (short)((int)&c + (int)&c) };
+short a[] = { (short)((__PTRDIFF_TYPE__)&c + (__PTRDIFF_TYPE__)&c) };
bash-3.2$

may work.

-- 
H.J.


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