Subject: Re: [boost] [bind] class template 'value' can corrupt compilability of sound code: Ticket #5141
From: Joachim Faulhaber (afojgo_at_[hidden])
Date: 2011-01-29 19:28:14
2011/1/30 Jeffrey Lee Hellrung, Jr. <jhellrung_at_[hidden]>:
> On 1/29/2011 3:38 PM, Joachim Faulhaber wrote:
>> 2011/1/30 Jeffrey Lee Hellrung, Jr.<jhellrung_at_[hidden]>:
>>> On 1/29/2011 3:04 PM, Joachim Faulhaber wrote:
>>>> value = ( some_attribute<Type>::value< 0)
>>>> //error C2059: syntax error : ')'
>>>> //IF class template value defined before
>>> Does adding parentheses, i.e.,
>>> value = ( (some_attribute<Type>::value)< 0 )
>>> help? If so, it could be an alternative to renaming the "value"
>>> template...although it could require quite a few more changes to boost
>> Yes, it does. That's the remedy I applied for "the affected code". But
>> obviously it's much better to heal the "malicious code". Fixing the
>> malicious code is a remedy for all the potential code by users that
>> could suffer from the effect.
> Re: "it's much better to heal the 'malicious code'", yes, usually, but maybe
> not in this case. This seems to fall into the same category as putting
> parentheses around min/max to prevent preprocessor macro substitution in the
> event that windows.h is included. True, we can actually change the
> offending code in this case unlike the min/max case, but in some instances
> (at least in theory) that would result in an unfortunate interface
> identifier change, and in the future, an interface identifier restriction.
> On the other hand, I agree, a policy such as "put parentheses around all
> nested integral static constants of a dependent type that are compared
> less-than some other constant" is not a pretty pill to swallow...
not pretty but we could support this new requirement by the inspect
tool. Still the problem is that user code that we can not control can
be spoiled by the effect.
>>> Not sure how many value struct templates there are under boost, but I
>>> wouldn't be surprised if there were another one for which renaming were
>>> *not* an option...
>> Unfortunately you may be right. I did a grep for
>> class value
>> and was happy to find only the *one* in boost bind. But for
>> struct value
>> we have 11 occurrences in boost.
> How many of these are struct or class templates?
All of them are templates, (this is boost code ;)
It's late in Europe. More on this from my part tomorrow ...
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk