Re: gcc 4.2 more strict check for function called through a non-compatible type

2007-03-25 Thread Ryan Hill
Ian Lance Taylor wrote: Ryan Hill [EMAIL PROTECTED] writes: Was there ever any action on this? AFAICS consensus was that the trap would be removed and this behaviour be documented as an extension. There was a bit more discussion of how exactly the documentation would be worded[i] and the

Re: gcc 4.2 more strict check for function called through a non-compatible type

2007-03-25 Thread Andrew Pinski
On 3/25/07, Ryan Hill [EMAIL PROTECTED] wrote: I couldn't find one so I've filed PR #31359. Apologies if it's a duplicate. I will again say, undocumented extensions don't exist (except for the case where the documentation is in the source and this was not one of those cases). This was just

Re: gcc 4.2 more strict check for function called through a non-compatible type

2007-03-23 Thread Ryan Hill
Mark Mitchell wrote: Ian Lance Taylor wrote: I realized that I am still not stating my position very clearly. I don't think we should make any extra effort to make this code work: after all, the code is undefined. I just think 1) we should not insert a trap; 2) we should not ICE. I

Re: gcc 4.2 more strict check for function called through a non-compatible type

2007-03-23 Thread Ian Lance Taylor
Ryan Hill [EMAIL PROTECTED] writes: Mark Mitchell wrote: Ian Lance Taylor wrote: I realized that I am still not stating my position very clearly. I don't think we should make any extra effort to make this code work: after all, the code is undefined. I just think 1) we should not

Re: gcc 4.2 more strict check for function called through a non-compatible type

2006-07-12 Thread Mark Mitchell
Andrew Haley wrote: Yuri Pudgorodsky writes: We can say something like: In GNU C, you may cast a function pointer of one type to a function pointer of another type. If you use a function pointer to call a function, and the dynamic type of the function pointed to by the

Re: gcc 4.2 more strict check for function called through a non-compatible type

2006-07-07 Thread Yuri Pudgorodsky
We can say something like: In GNU C, you may cast a function pointer of one type to a function pointer of another type. If you use a function pointer to call a function, and the dynamic type of the function pointed to by the function pointer is not the same as indicated by the static type

Re: gcc 4.2 more strict check for function called through a non-compatible type

2006-07-07 Thread Andrew Haley
Yuri Pudgorodsky writes: We can say something like: In GNU C, you may cast a function pointer of one type to a function pointer of another type. If you use a function pointer to call a function, and the dynamic type of the function pointed to by the function pointer is not

Re: gcc 4.2 more strict check for function called through a non-compatible type

2006-07-07 Thread Gabriel Dos Reis
Yuri Pudgorodsky [EMAIL PROTECTED] writes: [...] | The result of calling function pointer casted to sufficiently different | type is | a real example an undefined behavior. As I said earlier, it is fruitless to try to impose an ordering on the space of undefined behaviour. -- Gaby

Re: gcc 4.2 more strict check for function called through a non-compatible type

2006-07-07 Thread Yuri Pudgorodsky
Gabriel Dos Reis wrote: Yuri Pudgorodsky [EMAIL PROTECTED] writes: [...] | The result of calling function pointer casted to sufficiently different | type is | a real example an undefined behavior. As I said earlier, it is fruitless to try to impose an ordering on the space of undefined

Re: gcc 4.2 more strict check for function called through a non-compatible type

2006-07-07 Thread Gabriel Dos Reis
Yuri Pudgorodsky [EMAIL PROTECTED] writes: | Gabriel Dos Reis wrote: | Yuri Pudgorodsky [EMAIL PROTECTED] writes: | | [...] | | | The result of calling function pointer casted to sufficiently different | | type is | | a real example an undefined behavior. | | As I said earlier, it is

Re: gcc 4.2 more strict check for function called through a non-compatible type

2006-07-06 Thread Gabriel Dos Reis
Mark Mitchell [EMAIL PROTECTED] writes: | Ian Lance Taylor wrote: | | I realized that I am still not stating my position very clearly. I | don't think we should make any extra effort to make this code work: | after all, the code is undefined. I just think 1) we should not | insert a trap;

Re: gcc 4.2 more strict check for function called through a non-compatible type

2006-07-06 Thread Andrew Haley
Mark Mitchell writes: I also agree with Gaby that we should document this as an extension. If we go to the work of putting it back in, we should ensure that it continues to work for the foreseeable future. Part of that is writing down what we've decided. We can't make function

Re: gcc 4.2 more strict check for function called through a non-compatible type

2006-07-05 Thread Yuri Pudgorodsky
Andrew Pinski wrote: On Jul 4, 2006, at 5:07 PM, Yuri Pudgorodsky wrote: Can someone make the decision to reopen PR optimization/12085? And I posted a patch to do the same in Objective-C mode as C mode :). http://gcc.gnu.org/ml/gcc-patches/2004-08/msg01013.html That indeed will fix PR for

Re: gcc 4.2 more strict check for function called through a non-compatible type

2006-07-05 Thread Andrew Haley
Ian Lance Taylor writes: Andrew Haley [EMAIL PROTECTED] writes: Ian Lance Taylor writes: Yuri Pudgorodsky [EMAIL PROTECTED] writes: Compiling openssl-0.9.8b with gcc-4.2 snapshots, I found gcc 4.2 fortifies its check for function pointer conversion and generates

Re: gcc 4.2 more strict check for function called through a non-compatible type

2006-07-05 Thread Andrew Pinski
On Jul 5, 2006, at 2:36 AM, Yuri Pudgorodsky wrote: 1) with direct cast: (int (*)(int)) foo - warn/trap since 3.x 2) with cast through void fptr: (int (*)(int)) (int(*)()) foo - warn/trap since 4.2 current I don't see why you are invoking this undefined behavior anyways. What are you trying

Re: gcc 4.2 more strict check for function called through a non-compatible type

2006-07-05 Thread Gabriel Dos Reis
Andrew Haley [EMAIL PROTECTED] writes: [...] | If we're going to guarantee this stuff for the future, we'll have to | fix the bug, make sure it's doesn't destabilize the compiler and write | some test cases. If we're really serious about it we should make it a | documented extension to C. if

Re: gcc 4.2 more strict check for function called through a non-compatible type

2006-07-05 Thread Yuri Pudgorodsky
Andrew Pinski wrote: On Jul 5, 2006, at 2:36 AM, Yuri Pudgorodsky wrote: 1) with direct cast: (int (*)(int)) foo - warn/trap since 3.x 2) with cast through void fptr: (int (*)(int)) (int(*)()) foo - warn/trap since 4.2 current I don't see why you are invoking this undefined behavior

Re: gcc 4.2 more strict check for function called through a non-compatible type

2006-07-05 Thread Yuri Pudgorodsky
Gabriel Dos Reis wrote: Furthermore, I've read people suggesting that we are gratuitously broking code. That is misleading. The code was invoking undefined behaviour and, before, we did not make any explicit guarantee about the semantics. It is one thing to argue for changing gear; but,

Re: gcc 4.2 more strict check for function called through a non-compatible type

2006-07-05 Thread Gabriel Dos Reis
Yuri Pudgorodsky [EMAIL PROTECTED] writes: | Gabriel Dos Reis wrote: | Furthermore, I've read people suggesting that we are gratuitously | broking code. That is misleading. The code was invoking undefined | behaviour and, before, we did not make any explicit guarantee about | the semantics.

Re: gcc 4.2 more strict check for function called through a non-compatible type

2006-07-05 Thread Yuri Pudgorodsky
I apologize for presenting something which appears to be a strawman argument. That would never be my intent. Let me restate: I don't think gcc should ever insert a trap call for undefined code. We should only insert a trap call for code which will provably trap. We're currently breaking

Re: gcc 4.2 more strict check for function called through a non-compatible type

2006-07-05 Thread Andrew Haley
Ian Lance Taylor writes: Andrew Haley [EMAIL PROTECTED] writes: If we're going to guarantee this stuff for the future, we'll have to fix the bug, make sure it's doesn't destabilize the compiler and write some test cases. If we're really serious about it we should make it a

Re: gcc 4.2 more strict check for function called through a non-compatible type

2006-07-05 Thread Eric Botcazou
What do we do if compiler ICE generating code for valid C syntax with defined behavior? Fix it! Why should we go another way for valid C syntax with undefined behavior? The answer is in the question, no? -- Eric Botcazou

Re: gcc 4.2 more strict check for function called through a non-compatible type

2006-07-05 Thread Ian Lance Taylor
Ian Lance Taylor [EMAIL PROTECTED] writes: I personally don't agree that this needs to be a documented extension. I'm simply going on a more general rule which I tried to state above: I don't think we should insert a trap call for undefined code. I realized that I am still not stating my

Re: gcc 4.2 more strict check for function called through a non-compatible type

2006-07-05 Thread Yuri Pudgorodsky
For what it's worth, I tried to recreate the ICE after removing the trap insertion, but failed. So I'm not even sure the trap insertion is fixing a real problem any more. It works at the moment simply because it treats the call through a cast as a call through a function pointer, and

Re: gcc 4.2 more strict check for function called through a non-compatible type

2006-07-05 Thread Ian Lance Taylor
Andrew Haley [EMAIL PROTECTED] writes: If we make a change for openssh to allow this undefined behaviour, then do we agree to keep it working or not? If we agree that we will, then we have to at least add some test cases and we have to add some internal documentation to gcc. If we don't

Re: gcc 4.2 more strict check for function called through a non-compatible type

2006-07-05 Thread Andrew Haley
Ian Lance Taylor writes: Andrew Haley [EMAIL PROTECTED] writes: If we make a change for openssh to allow this undefined behaviour, then do we agree to keep it working or not? If we agree that we will, then we have to at least add some test cases and we have to add some internal

Re: gcc 4.2 more strict check for function called through a non-compatible type

2006-07-05 Thread Andrew Pinski
On Jul 5, 2006, at 8:38 AM, Ian Lance Taylor wrote: To me this is related to the point I raised at the steering committee panel discussion (I know you weren't there): I think we are too casual about breaking existing working code. What happens when a target comes along and passes different

Re: gcc 4.2 more strict check for function called through a non-compatible type

2006-07-05 Thread Daniel Jacobowitz
On Wed, Jul 05, 2006 at 09:11:32AM -0700, Andrew Pinski wrote: What happens when a target comes along and passes different pointers types differently. Like say a floating point pointer in the FP register and an pointer to an integer in the general purpose register, wouldn't that also break

Re: gcc 4.2 more strict check for function called through a non-compatible type

2006-07-05 Thread Ian Lance Taylor
Andrew Pinski [EMAIL PROTECTED] writes: On Jul 5, 2006, at 8:38 AM, Ian Lance Taylor wrote: To me this is related to the point I raised at the steering committee panel discussion (I know you weren't there): I think we are too casual about breaking existing working code. What happens

RE: gcc 4.2 more strict check for function called through a non-compatible type

2006-07-05 Thread Dave Korn
On 05 July 2006 17:12, Andrew Pinski wrote: On Jul 5, 2006, at 8:38 AM, Ian Lance Taylor wrote: To me this is related to the point I raised at the steering committee panel discussion (I know you weren't there): I think we are too casual about breaking existing working code. What happens

Re: gcc 4.2 more strict check for function called through a non-compatible type

2006-07-05 Thread Yuri Pudgorodsky
What happens when a target comes along and passes different pointers types differently. Like say a floating point pointer in the FP register and an pointer to an integer in the general purpose register, wouldn't that also break the code in question? Yes this is in theory but still saying

Re: gcc 4.2 more strict check for function called through a non-compatible type

2006-07-05 Thread Mike Stump
On Jul 4, 2006, at 5:18 PM, Andrew Pinski wrote: And I posted a patch to do the same in Objective-C mode as C mode :). http://gcc.gnu.org/ml/gcc-patches/2004-08/msg01013.html Is the reason that Objective-C was excluded been fixed? If so, while I don't like the semantics in place now, I'd

Re: gcc 4.2 more strict check for function called through a non-compatible type

2006-07-05 Thread Ian Lance Taylor
Mike Stump [EMAIL PROTECTED] writes: On Jul 4, 2006, at 5:18 PM, Andrew Pinski wrote: And I posted a patch to do the same in Objective-C mode as C mode :). http://gcc.gnu.org/ml/gcc-patches/2004-08/msg01013.html Is the reason that Objective-C was excluded been fixed? If so, while I

Re: gcc 4.2 more strict check for function called through a non-compatible type

2006-07-05 Thread Yuri Pudgorodsky
Ian Lance Taylor wrote: Mike Stump [EMAIL PROTECTED] writes: On Jul 4, 2006, at 5:18 PM, Andrew Pinski wrote: And I posted a patch to do the same in Objective-C mode as C mode :). http://gcc.gnu.org/ml/gcc-patches/2004-08/msg01013.html Is the reason that Objective-C was

Re: gcc 4.2 more strict check for function called through a non-compatible type

2006-07-05 Thread Gabriel Dos Reis
Ian Lance Taylor [EMAIL PROTECTED] writes: [...] | I personally don't agree that this needs to be a documented extension. | I'm simply going on a more general rule which I tried to state above: | I don't think we should insert a trap call for undefined code. If it should not a documented

Re: gcc 4.2 more strict check for function called through a non-compatible type

2006-07-05 Thread Gabriel Dos Reis
Ian Lance Taylor [EMAIL PROTECTED] writes: | Andrew Haley [EMAIL PROTECTED] writes: | | If we make a change for openssh to allow this undefined behaviour, | then do we agree to keep it working or not? If we agree that we will, | then we have to at least add some test cases and we have to add

Re: gcc 4.2 more strict check for function called through a non-compatible type

2006-07-05 Thread Mark Mitchell
Ian Lance Taylor wrote: I realized that I am still not stating my position very clearly. I don't think we should make any extra effort to make this code work: after all, the code is undefined. I just think 1) we should not insert a trap; 2) we should not ICE. I agree. If the inlining

gcc 4.2 more strict check for function called through a non-compatible type

2006-07-04 Thread Yuri Pudgorodsky
Compiling openssl-0.9.8b with gcc-4.2 snapshots, I found gcc 4.2 fortifies its check for function pointer conversion and generates abort for PEM_read_X509_AUX() and similar wrappers. There was an old discussion about casting pointer to function issue - Why does casting a function generate a

Re: gcc 4.2 more strict check for function called through a non-compatible type

2006-07-04 Thread Ian Lance Taylor
Yuri Pudgorodsky [EMAIL PROTECTED] writes: Compiling openssl-0.9.8b with gcc-4.2 snapshots, I found gcc 4.2 fortifies its check for function pointer conversion and generates abort for PEM_read_X509_AUX() and similar wrappers. Personally speaking, I agree with you that the compiler should

Re: gcc 4.2 more strict check for function called through a non-compatible type

2006-07-04 Thread Andrew Haley
Ian Lance Taylor writes: Yuri Pudgorodsky [EMAIL PROTECTED] writes: Compiling openssl-0.9.8b with gcc-4.2 snapshots, I found gcc 4.2 fortifies its check for function pointer conversion and generates abort for PEM_read_X509_AUX() and similar wrappers. Personally speaking, I agree

Re: gcc 4.2 more strict check for function called through a non-compatible type

2006-07-04 Thread Ian Lance Taylor
Andrew Haley [EMAIL PROTECTED] writes: Ian Lance Taylor writes: Yuri Pudgorodsky [EMAIL PROTECTED] writes: Compiling openssl-0.9.8b with gcc-4.2 snapshots, I found gcc 4.2 fortifies its check for function pointer conversion and generates abort for PEM_read_X509_AUX() and

Re: gcc 4.2 more strict check for function called through a non-compatible type

2006-07-04 Thread Yuri Pudgorodsky
So that ICE still exist for objective-c and is just hidden with warn/trap workaround for c/c++: double foo(double arg) { return arg; } int bar(int d) { d = ((int (*) (int)) foo)(d); return d *d; } If you compile the above example in objective-c mode (gcc -O3 -x objective-c), current

Re: gcc 4.2 more strict check for function called through a non-compatible type

2006-07-04 Thread Andrew Pinski
On Jul 4, 2006, at 5:07 PM, Yuri Pudgorodsky wrote: Can someone make the decision to reopen PR optimization/12085? And I posted a patch to do the same in Objective-C mode as C mode :). http://gcc.gnu.org/ml/gcc-patches/2004-08/msg01013.html -- Pinski