indent munges const cpp methods

"Simmons, Aaron" <[email protected]> Tue, 15 Dec 2009 15:45:10 -0500
Newsgroups gmane.comp.gnu.indent.bugs
Message-ID <9BF48DB58688484396C43886E8E7AD88067EB9C149@RSHBGXMBCLS1.rosettastone.local>
Run this C++ code through indent 2.2.10 with just the defaults:



        #include <stdio.h>



        typedef struct TestThing_s

        {

          int writeToFile (char *filename, const char *encoding = NULL) const;

        } TestThing_t;





        int

        TestThing_t::writeToFile (char *filename, const char *encoding) const

        {

          return 0;

        }



And you will get:



        #include <stdio.h>



        typedef struct TestThing_s

        {

          int writeToFile (char *filename, const char *encoding = NULL) const;

        } TestThing_t;





        int

        TestThing_t::writeToFile (char *filename, const char *encoding) const const

        {

          return 0;

        }



Notice the "const const" on the writeToFile implementation.  As you might expect, this doesn't compile:

        test.cpp:10: error: duplicate cv-qualifier





btw, this happens on both Ubuntu and Mac OS X.







Thanks,

aaron