Giter VIP home page Giter VIP logo

Comments (6)

daveedvdv avatar daveedvdv commented on July 20, 2024

from cxx-abi.

zygoloid avatar zygoloid commented on July 20, 2024

Added a pull request describing the rule I think we've agreed on. This matches EDG's behavior, mostly matches Clang's and is substantially different from GCC's :)

In particular, Clang only renumbers closure types in template instantiations, and inherits the numbering for everything else. I believe that is a valid approach in language as it stands today, but only because there happens to be no way to pack-expand any numbered entity other than a closure type yet. I expect that to change, so adopting EDG's rule (effectively: renumber everything during template instantiation, as if we instantiated by token replay) seems best.

from cxx-abi.

rjmccall avatar rjmccall commented on July 20, 2024

Is the different treatment of constexpr if in templates and non-templates justifiable?

from cxx-abi.

rjmccall avatar rjmccall commented on July 20, 2024

I'm also uncertain about consistently using the last token in the entity. That rule seems to be justifiable for lambdas, but I'm not sure it's reasonable for e.g. static locals. While static locals cannot be lexically nested in the same semantic context in standard C++, they can be lexically nested in vendor-extended C++ due to statement-expressions, and I think we might expect a naive compiler to pick a discriminator as soon as the declarator was processed rather than after processing the initializer.

from cxx-abi.

zygoloid avatar zygoloid commented on July 20, 2024

Is the different treatment of constexpr if in templates and non-templates justifiable?

Yes, I think so; constexpr if does different things in templates and non-templates.

In a non-template, it's normal code that's just not emitted (we also turn off return type deduction, but not much else). In particular, you can instantiate a template in the not-chosen branch, using a local type from the not-chosen branch, and end up needing to emit a symbol (eg, the initializer for a templated variable). So we must number things in the non-template case.

In a template, constexpr if fully discards the not-chosen branch: we don't even substitute into it, so there's nothing we could number even if we wanted to.

I'm also uncertain about consistently using the last token in the entity.

I think using the token at which the identity of the entity is known (the last token in the declaration, excluding a definition / body / initializer) would be reasonable. For a lambda, that'd mean you pick the {, not the } as in the current pull request, but I think those options are equivalent anyway, as everything inside the braces can use the lambda itself as its numbering context..

from cxx-abi.

rjmccall avatar rjmccall commented on July 20, 2024

So we must number things in the non-template case.

Hmm. This design is quite surprising to me; I understand why it's desirable for discarded sub-statements to still be well-formed, but I'm surprised they're not at least considered to be some form of unevaluated code so that its uses are never ODR-uses and we're not even tempted to actually instantiate templates, much less emit any code for them. Seems like an unforced error.

For a lambda, that'd mean you pick the {, not the } as in the current pull request, but I think those options are equivalent anyway, as everything inside the braces can use the lambda itself as its numbering context.

I considered that and came to the same conclusion, but you're right that it would be more consistent to use the earlier token just to underline the point. The only reason not to would be if something about the body ever fed into the signature, but since we control this particular definition of "signature", it's easy enough to simply commit to not doing that.

from cxx-abi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.