3

Expression templates (for example) represent computations in a deeply nested class template. This can result in very long type names when the templates are instantiated.

Is the length of a type name (or what's the correct term for it here?) constrained in the C++ language? And is there some hard limit for the resulting mangled symbols?

florestan
  • 4,405
  • 2
  • 14
  • 28
  • 2
    The Standard does not constrain symbol length(s) but it does note that implementations may have limits https://eel.is/c++draft/implimits You will need to read your implantation's documentation for this. For example _"An identifier is an __arbitrarily__ long sequence of letters and digits..."_ https://eel.is/c++draft/lex.name – Richard Critten Jan 31 '21 at 14:14
  • Thank you. Do you wanna make this an answer so I can close the question? – florestan Jan 31 '21 at 14:43
  • 1
    Mark de Wever started a POC for Clang ~1 year ago to document its (/some of its) [implimits], as per his commit [D72053](https://reviews.llvm.org/D72053) and related [cfe-dev] [mail thread](https://lists.llvm.org/pipermail/cfe-dev/2020-January/064177.html). I don't know what happened to that though, but one concern from the mail thread was that documenting the limits could make users believe that they would be guaranteed to be respected, whereas the current implementation makes no such guarantee (it _could_ misbehave e.g. for too deep template recursion depth). – dfrib Feb 01 '21 at 11:23
  • @dfrib I thing clang (all compilers) should be doing this: _"... Every implementation shall document those limitations where known...."_ https://eel.is/c++draft/implimits – Richard Critten Feb 01 '21 at 14:50
  • 1
    @RichardCritten The problem (/implementor feature?) is the _"[...] where known"_, which basically means that the normative text of that particular sentence have no normative value, and can be ignored. – dfrib Feb 01 '21 at 14:52

0 Answers0