« ooc-cholesky | Main | Samba on Debian »

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

This page contains a single entry from the blog posted on November 24, 2007 7:53 PM.

The previous post in this blog was ooc-cholesky.

The next post in this blog is Samba on Debian.

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

Powered by
Movable Type 3.35