r179035 - <rdar://problem/13540921> Cope with deduced 'auto' in a C++11 for-range loop that is actually an Objective-C fast enumeration loop.

Douglas Gregor dgregor at apple.com
Tue Apr 16 00:30:31 PDT 2013


On Apr 16, 2013, at 7:43 AM, David Blaikie <dblaikie at gmail.com> wrote:

> On Mon, Apr 8, 2013 at 2:20 PM, Douglas Gregor <dgregor at apple.com> wrote:
>> 
>> On Apr 8, 2013, at 2:19 PM, John McCall <rjmccall at apple.com> wrote:
>> 
>> On Apr 8, 2013, at 12:42 PM, Erik Verbruggen <erik.verbruggen at me.com> wrote:
>> 
>> Pardon my ignorance, but why a warning? Or to rephrase it: why could this be
>> problematic at all to fail with -Werror?
>> 
>> 
>> There's no good reason to use "auto" in a situation where it will always
>> infer as "id".  People should either explicitly provide a more specific
>> type, in which case uses of the value will actually be meaningfully
>> type-checked, or they should type "id", which is shorter.
>> 
>> 
>> … and it's not an error because this could legitimately happen during
>> template instantiation, where we suppress the warning.
> 
> But if the warning is appropriately suppressed/doesn't fire in
> templates, why is that scenario a reason not to have it be an error?

Because we tend not to have different *semantics* in templates vs. non-templates, even if we apply different heuristics for warnings.

	- Doug



More information about the cfe-commits mailing list