C++ PATCH to implement C++20 P0892R2 - explicit(bool)

Nathan Sidwell nathan@acm.org
Wed Oct 3 16:44:00 GMT 2018


On 10/2/18 5:25 PM, Marek Polacek wrote:
> On Mon, Oct 01, 2018 at 07:47:10PM -0400, Jason Merrill wrote:
>> On Mon, Oct 1, 2018 at 6:41 PM Marek Polacek <polacek@redhat.com> wrote:
>>>
>>> This patch implements C++20 explicit(bool), as described in:
>>> <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0892r2.html>.
>>>
>>> I tried to follow the noexcept specifier implementation where I could, which
>>> made the non-template parts of this fairly easy.  To make explicit(expr) work
>>> with dependent expressions, I had to add DECL_EXPLICIT_SPEC to lang_decl_fn,
>>> which serves as a vessel to get the explicit-specifier to tsubst_function_decl
>>> where I substitute the dependent arguments.
>>
>> What's the impact of that on memory consumption?  I'm nervous about
>> adding another word to most functions when it's not useful to most of
>> them.  For several similar things we've been using hash tables on the
>> side.
> 
> Yeah, that is a fair concern.  I'm not sure if I know of a good way to measure
> it.  I took wide-int.ii and ran /usr/bin/time -v ./cc1plus; then it's roughly
> Maximum resident set size (kbytes): 95020
> vs.				
> Maximum resident set size (kbytes): 95272
> which doesn't seem too bad but I don't know if it proves anything.
> 
> If we went with the hash table, would it work like this?
> 1) have a hash table mapping decls (key) to explicit-specifiers
> 2) instead of setting DECL_EXPLICIT_SPEC put the parsed explicit-specifier
>     into the table
> 3) in tsubst_function_decl look if the fn decl is associated with any
>     explicit-specifier, if it is, substitute it, and set DECL_NONCONVERTING_P
>     accordingly.

Sounds right, maybe with the flag idea I mentioned in the other email to 
say it's worth looking in the hash table.  Hashing can be by tree 
address of course.

natha

-- 
Nathan Sidwell



More information about the Gcc-patches mailing list