-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mangling for designated initialization #25
Comments
We should probably assume that implementations will support the full C99 feature as an extension, which means we need a designator for [3]. |
How are those distinct? I'm probably missing something, but to me those two look like two instantiations of function f, which are only possible if the template parameter T has either a member "a" then "b", or "c" then "d", which all can be initialised from integers. If you passed a type T that has a, b, c, d or c, d, a, b, then it would be an ambiguous overload. Going to read the paper now to see if I can answer my own question. |
They are distinct due to [temp.over.link]p4-6: corresponding parameter types contain expressions that name template parameters, and those expressions are neither equivalent nor functionally equivalent. I believe you may be correct that it is not possible to unambiguously use them both in a single translation unit for an arbitrary set of template arguments. Unfortunately, that does not matter for the ODR; if it did, I think there would be a lot of stuff we wouldn't have to mangle. |
Thanks for the reference. I was going to say that we don't need the values that were used to initialise since they aren't used in the actual call, but then I realised that you could have: template<typename T> void f(decltype(T{.a = 1, .b = nullptr})); If the conversion from nullptr to b's type fails, then this is not a suitable overload. That means we do need the values used. Anyway, as you said, we may expect compilers to support C99 extensions, like nested initialisation. So if we had: template<typename T> void f(decltype(T{.a.b = 1, .b = 2})); Would that mangle instead as I assume an array declaration Finally, extracted from the kernel: [0 ... __NR_syscall_max] = &sys_ni_syscall, becomes |
My suggestion was that it would mangle as
That would mean
Sure, if we want to support GNU extensions as well as C99 extensions, maybe |
I imagined that it would terminate at the first L or X, but sure, repeating For the array, I'd recommend [obj[1]] = 2 mangle as In fact, for the dot, maybe
Just being careful if some vendor wants to do this. But I'd recommend |
This is an arbitrary expression context, not something like a <template-arg> with a very restrictive grammar. So we can't use that rule, and can't use |
Ah, right, I see
I hadn't noticed it before, I thought it was new and then allowed for a new grammar expansion. (shouldn't there be a + after |
Fixed (to be an <expression>*). |
While you're at it...
The |
Also fixed, thanks! |
PR has been merged. |
Now that we've voted designated initialization into the C++ draft, we need a mangling. These are distinct:
Something like
il di 1a Li1E di 1b Li1E E
would be enough for what we've voted into C++ (anddi 1a di 1b
could be used for a multi-level.a.b
designator, which implementations will likely support as an extension).The text was updated successfully, but these errors were encountered: