On Sep 25, 2008, at 2:49 PM, Mike Stump wrote:

> On Sep 25, 2008, at 3:13 AM, steve naroff wrote:
>> Thanks!  Unfortunately, this means the following will be considered  
>> an error.
>>
>> void foo() {
>>  int (^xx)(const char *s) = ^(char *s) { return 1; };
>> }
>
> The pointer version of this is a violation of the C and C++  
> standards.  Blocks should be the same way.
>
>> Can you try this on your gcc? (I don't have it handy).
>
> With -ansi -pedantic-errors and pointers, they both error out in  
> gcc.  As blocks, in C++ it gives an error.

O.k. I'm happy to change it back to an error.

> In C, it just swallows it, no warning even.  The C behavior is  
> wrong, I filed 6246965 to cover it.  The C++ behavior is as expected.
>

The broken C behavior in GCC is what motivated my change. Since we are  
compiling blocks code with both gcc & clang, I want to make sure we  
are source compatible. I shouldn't assume GCC is bug free:-)

So...whatever we do with type checking blocks, gcc and clang need to  
agree.

>> Fariborz said we should treat this the same as function pointer  
>> assignments (which is why I made the change...).
>
> Ah, but there is a laxity that I don't think he meant to include.   
> Blocks don't need this laxity as there isn't 30 year old dusty deck  
> blocks code.  Also, laxity for const violations is, well, a - 
> fpermissive type thang.

Makes sense. Thanks for catching this!

snaroff
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to