« October 2007 | Main | December 2007 »

November 2007 Archives

November 24, 2007

GCC bug with const members

I found my first GCC bug the other day. I was reading Herb Sutters' Exceptional C++ book, and noticed some interesting advice about auto_ptr. He suggests that we use const auto_ptr wherever possible, and also use auto_ptr member data for classes. The member data suggestion is sort of strange, because it ignores his first suggestion and uses non-const auto_ptr members. This, in turn, leads to more code to disable class copy constructors and assignment.

The better solution is to use a const auto_ptr member, which is initialized upon construction. Copy and assignment constructors should be automatically disabled. And they are in Intel's C++ compiler, Microsoft's, and Comeau's. Unfortunately, GCC has a bit of a problem. The default copy constructor is perfectly willing to ignore const constraints on const member copy operations.

I posted to the USENET C++ moderated group and confirmed that this was a GCC bug, then submitted to GCC's bugzilla.

About November 2007

This page contains all entries posted to Coding Is Hard in November 2007. They are listed from oldest to newest.

October 2007 is the previous archive.

December 2007 is the next archive.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type 3.35