www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Identifier too long - Should this be considered a bug?

reply "Janice Caron" <caron800 googlemail.com> writes:
I've just been writing this program. It's very heavy on templates.

I guess I just added one alias too many. My latest compile failed with
the error message:

Error: identifier ... is too long by 2210 characters.

(I snipped the actual identifier name for obvious reasons). So
basically, an alias expands to a template which contains other aliases
which in turn expand to templates - and so on out to many levels. I
had this really cool and beautiful code going, when suddenly - wham!
Proceed no further!

Why should there be an arbitrary limit on compiler-generated identfier names?

The human-readable names were all of reasonable length, but the
mangled name that the compiler comes up with is too long for itself.

To me, this feels like a compiler bug. I don't feel that I, as a
programmer, did anything wrong. Why should there be a limit to how
deeply one can nest template parameters?

Anyway, I put this to the rest of you. Do we care? Can we call this a
bug? Or am I just wanting too much?
Oct 13 2007
next sibling parent reply Daniel Keep <daniel.keep.lists gmail.com> writes:
Janice Caron wrote:
 I've just been writing this program. It's very heavy on templates.
 
 I guess I just added one alias too many. My latest compile failed with
 the error message:
 
 Error: identifier ... is too long by 2210 characters.
 
 (I snipped the actual identifier name for obvious reasons). So
 basically, an alias expands to a template which contains other aliases
 which in turn expand to templates - and so on out to many levels. I
 had this really cool and beautiful code going, when suddenly - wham!
 Proceed no further!
 
 Why should there be an arbitrary limit on compiler-generated identfier names?
 
 The human-readable names were all of reasonable length, but the
 mangled name that the compiler comes up with is too long for itself.
 
 To me, this feels like a compiler bug. I don't feel that I, as a
 programmer, did anything wrong. Why should there be a limit to how
 deeply one can nest template parameters?
 
 Anyway, I put this to the rest of you. Do we care? Can we call this a
 bug? Or am I just wanting too much?

If I remember correctly, this is a limitation of the OBJ file format that the DMD backend produces. This in turn is what DMD's linker uses. The linker that's written entirely in assembler, and no one wants to touch. ;) I seem to recall something a while back about taking the mangled names and compressing them, but I'm not sure what happened with that. Although I do think this shouldn't really happen, it only crops up every once in a blue moon. As far as I can remember, the only other person to hit this was Kirk. Given that fixing this properly would mean significant changes to the linker and the DMD backend, and that the limit is pretty huge anyway, I'm not sure if this should be a priority. -- Daniel
Oct 13 2007
parent BCS <ao pathlink.com> writes:
Reply to Daniel,

 I seem to recall something a while back about taking the mangled names
 and compressing them, but I'm not sure what happened with that.

thay are now.
 
 Although I do think this shouldn't really happen, it only crops up
 every once in a blue moon.  As far as I can remember, the only other
 person to hit this was Kirk.

I have hit it to.
  Given that fixing this properly would
 mean significant changes to the linker and the DMD backend, and that
 the limit is pretty huge anyway, I'm not sure if this should be a
 priority.

Several solutions have been suggested (use the MD5 has for instance) but nothing has happened. At this time the solution is to work on Linux (ELF object files have not symbol length limits) but you still get blotted files and sooner or later DMD will run out of RAM (I've pushed it to 1GB).
 
 -- Daniel
 

Oct 13 2007
prev sibling next sibling parent Frits van Bommel <fvbommel REMwOVExCAPSs.nl> writes:
(Daniel beat me to posting, but hadn't posted yet when I started typing 
this)

Janice Caron wrote:
 I've just been writing this program. It's very heavy on templates.
 
 I guess I just added one alias too many. My latest compile failed with
 the error message:
 
 Error: identifier ... is too long by 2210 characters.
 
 (I snipped the actual identifier name for obvious reasons). So
 basically, an alias expands to a template which contains other aliases
 which in turn expand to templates - and so on out to many levels. I
 had this really cool and beautiful code going, when suddenly - wham!
 Proceed no further!
 
 Why should there be an arbitrary limit on compiler-generated identfier names?

You're using DMD on Windows, right? IIRC the object format it uses (OMF) places that restriction on the names. You may want to try mingw-gdc (from http://sourceforge.net/project/showfiles.php?group_id=154306 or http://sourceforge.net/project/showfiles.php?group_id=168193). I'm not sure if those packages includes a linker, if not, get the binutils from http://sourceforge.net/project/showfiles.php?group_id=2435. I'm not sure what limits COFF (the object format mingw uses) places, but they're probably less restrictive than OMF since IIRC it's a newer format.
 The human-readable names were all of reasonable length, but the
 mangled name that the compiler comes up with is too long for itself.
 
 To me, this feels like a compiler bug. I don't feel that I, as a
 programmer, did anything wrong. Why should there be a limit to how
 deeply one can nest template parameters?
 
 Anyway, I put this to the rest of you. Do we care? Can we call this a
 bug? Or am I just wanting too much?

This is a limitation that people have run into before (search the NGs, there should be earlier threads on this) but I'm not sure whether it can be considered a bug instead of a limitation of the toolchain. Also, if I'm right that this is a restriction of OMF, the only way to fix it would be for DMD to switch object formats on Windows, which Walter IIRC said would be a lot of work.
Oct 13 2007
prev sibling parent reply "Janice Caron" <caron800 googlemail.com> writes:
It's OK. I've decided to do things differently so as not to encounter
the problem.

Thanks guys.
Oct 13 2007
parent "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"Janice Caron" <caron800 googlemail.com> wrote in message 
news:mailman.418.1192276971.16939.digitalmars-d puremagic.com...
 It's OK. I've decided to do things differently so as not to encounter
 the problem.

 Thanks guys.

I also ran into this with my MiniD binding library (very similar to Kirk's Pyd), but at least for me it was very easy to solve. Instead of writing something like: WrapModule!( "moduleName", AMember, ... 150 more members ... )(); I did: mixin WrapModule!(...) WM; WM.WM(); The compiler won't generate that extremely long symbol name if you use it in a mixin. The compiler does actually compress the symbol names; you'll see all kinds of scary characters if you i.e. use -profile or -cov, or just look at the debug symbols.
Oct 13 2007