jump to navigation

Bad C++ March 31, 2006

Posted by gordonwatts in computers, physics.
trackback

This is more bad humor of the nerdy type. Usually I, and almost everyone else, writes code that looks something like the following:

for (int i = 0; i < 10; i++) {
  do_something(i);
}

When that code is compiled all the referenced symbols are written out. In this example "do_something". In order to keep ROOT happy on Windows we need to scan these symbol names. During a recent scan of some of my code the tool popped up with an error "Sorry, symbol name is longer than 2048 character – I'm crashing now!" (ok, the message was a little more cryptic than that, and ended with the dreaded "core dumped" message).

Can you imagine typing a symbol name as long as 2048 characters? The long symbol, it turns out, wasn't a bug — the template features of C++ can easily cause this to happen — but it is amazing to think there is something with a name in your code that is 2048 characters long. When I send email to Rene he laughed at me and told me to post this… What can I say? If that is what it takes to get the 2048 limit raised in the ROOT tool…

Comments»

1. தமிழன் - March 31, 2006

Ever visited south india? Its culturally much richer and older. While north india is mainly influenced by invaders (aryans,mughals, the british etc..), south india still maintains centuries old native traditions, many predating aryan indian civilization.

2. What Does a Cosmologist Do At Microsoft? « Life as a Physicist - September 21, 2006

[…] Part of the reason I stumbled on this is that his group (?) has done a lot with functional languages and most recently has been working on the LINQ project. I’ve mentioned before that I wonder if C++ is the wrong direction for us in physics. Part of the reason is I see it as a basically dead language. Even the new features that are being planned in the TR1 timeframe strike me as fixes. Many other languages are rapidly evolving: python, ruby, java, C#, and (Brian’s favorite — you’ll have to watch the video) VisualBasic. I can’t help but wonder if some of these new technologies can make our lives in physics easier. […]

3. aqq - December 12, 2008

It’s not the C++ fault. Name mangling is not defined in the standard and left out to the vendors.

4. Gordon Watts - December 12, 2008

That is true, but still, the way templates work it lends itself to these sorts of things, and that is C++’s fault!🙂


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: