|
Boost : |
Subject: Re: [boost] [bind] class template 'value' can corrupt compilability of sound code: Ticket #5141
From: Jeffrey Lee Hellrung, Jr. (jhellrung_at_[hidden])
Date: 2011-01-29 19:01:55
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
>> code...
>
> 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...
[...]
>>> Although I frankly don't know, how exactly msvc is derailed, it seems
>>> to have problems with 'value' in
>>>
>>> some_attribute<Type>::value< 0
>>
>> ...worth filing a bug in the MS Connect database?
>
> ... no experience with that here :-/
I think you'll want
http://connect.microsoft.com/VisualStudio
If you give me sample cpp, I can verify that I get the same problem (I
only have MSVC9 installed) and submit the bug request on your behalf.
[...]
>> 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? I assume the problem
only manifests itself if value is a struct or class template.
I would also hope it wouldn't matter whether one used the keyword
"struct" or "class" to declare the value template ;)
- Jeff
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk