[Bug c++/12246] New: __attribute__ not able to be placed on inline ctors

Bruce at Fitzsimons dot org gcc-bugzilla@gcc.gnu.org
Thu Sep 11 14:54:00 GMT 2003


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12246

           Summary: __attribute__ not able to be placed on inline ctors
           Product: gcc
           Version: 3.2.3
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: Bruce at Fitzsimons dot org
                CC: gcc-bugs at gcc dot gnu dot org

__attribute__ attributes are not able to be placed on inline ctors, which is a
bit frustrating.

Sometimes inline ctors are used in header files, esp. when doing a thin layer of
inheritance around an existing object ie only the base class needs
initialisation, there are no new member variables. 

This is often the case for deriving exceptions, where a new type is desired (for
specific catch'es) but no new methods or members are defined.

A simple example (not the inheritance case)

class A
{
public:
    A(int _anInt)  __attribute__ ((deprecated)) { anInt = _anInt; }
private:
    int anInt;
};

int main(void) {
    A aInstance(42);
}

Fails to parse:
g++ test.cc
test.cc:4: syntax error before `{' token
test.cc:5: semicolon missing after declaration of `A'
test.cc: In function `int main()':
test.cc:10: no matching function for call to `A::A(int)'
test.cc:2: candidates are: A::A(const A&)



More information about the Gcc-bugs mailing list