Re: Add uninitialized attribute?

2010-08-31 Thread Andrew Haley
On 08/30/2010 03:50 PM, Vincent Lefevre wrote: On 2010-08-30 14:46:57 +0200, Michael Matz wrote: int x = x; is the way GCC offers this idiom since about forever, no need for an attribute. Downthread I see that people worry about this generating an actual (uninitialized) access to x. They

Re: Add uninitialized attribute?

2010-08-31 Thread Mark Mitchell
On 8/31/2010 1:19 AM, Andrew Haley wrote: On 08/30/2010 03:50 PM, Vincent Lefevre wrote: On 2010-08-30 14:46:57 +0200, Michael Matz wrote: int x = x; is the way GCC offers this idiom since about forever, no need for an attribute. Downthread I see that people worry about this generating an

Re: Add uninitialized attribute?

2010-08-30 Thread Michael Matz
Hi, On Fri, 20 Aug 2010, H.J. Lu wrote: int x = 0; to silence gcc from uninitialized warnings when I know it is unnecessary. Is that a good idea to add int x __attribute__ ((uninitialized)); to tell compiler that it is OK for x to be uninitialized? int x = x; is the way GCC offers

Re: Add uninitialized attribute?

2010-08-30 Thread Vincent Lefevre
On 2010-08-30 14:46:57 +0200, Michael Matz wrote: int x = x; is the way GCC offers this idiom since about forever, no need for an attribute. Downthread I see that people worry about this generating an actual (uninitialized) access to x. They are confused. This is not a good idea as int

Re: Add uninitialized attribute?

2010-08-23 Thread Richard Guenther
On Sat, Aug 21, 2010 at 11:43 AM, Florian Weimer f...@deneb.enyo.de wrote: * H. J. Lu: Sometime I have to do int x = 0; to silence gcc from uninitialized warnings when I know it is unnecessary. I guess the official idiom is  int x = x; That's what I thought as well, so I am confused.

Re: Add uninitialized attribute?

2010-08-21 Thread Florian Weimer
* H. J. Lu: Sometime I have to do int x = 0; to silence gcc from uninitialized warnings when I know it is unnecessary. I guess the official idiom is int x = x; and it is somewhat used in the GNU project although it is not portable.

RE: Add uninitialized attribute?

2010-08-21 Thread Kreitzer, David L
...@codesourcery.com] Sent: Friday, August 20, 2010 7:33 PM To: H.J. Lu Cc: Bernd Schmidt; Ian Lance Taylor; GCC Development; Kreitzer, David L; Girkar, Milind Subject: Re: Add uninitialized attribute? H.J. Lu wrote: void *undef __attribute__ ((uninitialized)); // Or something similar foo (undef

Re: Add uninitialized attribute?

2010-08-21 Thread David Brown
Mark Mitchell wrote: Bernd Schmidt wrote: int x __attribute__ ((uninitialized)); to tell compiler that it is OK for x to be uninitialized? Better to call it initialized, analogous to attribute used/unused. I agree. I think the general idea is reasonable. I also think it might be worth

Re: Add uninitialized attribute?

2010-08-21 Thread Andrew Haley
On 08/21/2010 10:43 AM, Florian Weimer wrote: * H. J. Lu: Sometime I have to do int x = 0; to silence gcc from uninitialized warnings when I know it is unnecessary. I guess the official idiom is int x = x; and it is somewhat used in the GNU project although it is not portable.

Re: Add uninitialized attribute?

2010-08-21 Thread Andrew Pinski
On Sat, Aug 21, 2010 at 8:21 AM, Andrew Haley a...@redhat.com wrote: Ewww, yuck.  I think this'll get a read from uninitialized message from Valgrind.  It's undefined behaviour too. Not to mention there is a patch to get rid of this idiom and warn about it even without uninitialized warning.

Re: Add uninitialized attribute?

2010-08-21 Thread Florian Weimer
* Andrew Haley: On 08/21/2010 10:43 AM, Florian Weimer wrote: * H. J. Lu: Sometime I have to do int x = 0; to silence gcc from uninitialized warnings when I know it is unnecessary. I guess the official idiom is int x = x; and it is somewhat used in the GNU project although it

Re: Add uninitialized attribute?

2010-08-21 Thread Mark Mitchell
Kreitzer, David L wrote: There are some situations where an __undefined__ keyword would be useful Thanks for the example. I suppose that in C the natural syntax is a pseudo-function that takes a type, rather than an object, as an argument: __undefined__(int) __undefined__(vector float)

Re: Add uninitialized attribute?

2010-08-20 Thread Diego Novillo
On 10-08-20 15:42 , H.J. Lu wrote: Hi, Sometime I have to do int x = 0; to silence gcc from uninitialized warnings when I know it is unnecessary. Is that a good idea to add int x __attribute__ ((uninitialized)); to tell compiler that it is OK for x to be uninitialized? Seems to me that

Re: Add uninitialized attribute?

2010-08-20 Thread Ian Lance Taylor
H.J. Lu hjl.to...@gmail.com writes: Sometime I have to do int x = 0; to silence gcc from uninitialized warnings when I know it is unnecessary. Is that a good idea to add int x __attribute__ ((uninitialized)); to tell compiler that it is OK for x to be uninitialized? I think the

Re: Add uninitialized attribute?

2010-08-20 Thread Bernd Schmidt
On 08/20/2010 10:51 PM, Ian Lance Taylor wrote: H.J. Lu hjl.to...@gmail.com writes: Sometime I have to do int x = 0; to silence gcc from uninitialized warnings when I know it is unnecessary. Is that a good idea to add int x __attribute__ ((uninitialized)); to tell compiler that it is

Re: Add uninitialized attribute?

2010-08-20 Thread H.J. Lu
On Fri, Aug 20, 2010 at 1:57 PM, Bernd Schmidt ber...@codesourcery.com wrote: On 08/20/2010 10:51 PM, Ian Lance Taylor wrote: H.J. Lu hjl.to...@gmail.com writes: Sometime I have to do int x = 0; to silence gcc from uninitialized warnings when I know it is unnecessary.  Is that a good idea

Re: Add uninitialized attribute?

2010-08-20 Thread Mark Mitchell
Bernd Schmidt wrote: int x __attribute__ ((uninitialized)); to tell compiler that it is OK for x to be uninitialized? Better to call it initialized, analogous to attribute used/unused. I agree. I think the general idea is reasonable. I also think it might be worth spending a few

Re: Add uninitialized attribute?

2010-08-20 Thread Mark Mitchell
H.J. Lu wrote: void *undef __attribute__ ((uninitialized)); // Or something similar foo (undef); Compiler can pass some junk to foo. I don't think that's a very good idea. If we need this, which I doubt, it should be something like a new __undefined__ keyword, that expands to an