public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/47634] New: Incorrect checking of attribute format printf on constructor of derived class with virtual base
@ 2011-02-07 14:50 dan at randomdan dot homeip.net
  2021-08-09 18:26 ` [Bug c++/47634] " pinskia at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: dan at randomdan dot homeip.net @ 2011-02-07 14:50 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: Incorrect checking of attribute format printf on
                    constructor of derived class with virtual base
           Product: gcc
           Version: 4.4.5
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: dan@randomdan.homeip.net


Given the below code, gcc produces the following warnings:

exception.cpp: In function 'int main(int, char**)':
exception.cpp:28: warning: format not a string literal and no format arguments

Changing the __attribute__ on VDerived's constructor to be the same as Derived
produces the following error:
exception.cpp:9: error: format string argument not a string type

Compiled simply with:
g++ exception.cpp

class Base {
    public:
        Base() {
        }
};

class VDerived : public virtual Base {
    public:
        VDerived(int x, const char * f, ...) __attribute__((format(printf, 5,
6)));
};

class Derived : public Base {
    public:
        Derived(int x, const char * f, ...) __attribute__((format(printf, 3,
4)));
};

VDerived::VDerived(int x, const char * f, ...)
{
}

Derived::Derived(int x, const char * f, ...)
{
}

int
main(int, char **)
{
    throw VDerived(1, "%s %d", "foo", 1);
    throw Derived(1, "%s %d", "bar", 1);
}


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-05-07 14:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-07 14:50 [Bug c++/47634] New: Incorrect checking of attribute format printf on constructor of derived class with virtual base dan at randomdan dot homeip.net
2021-08-09 18:26 ` [Bug c++/47634] " pinskia at gcc dot gnu.org
2022-03-31 22:37 ` mpolacek at gcc dot gnu.org
2022-05-07 14:44 ` cvs-commit at gcc dot gnu.org
2022-05-07 14:59 ` mpolacek at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).