[Bug c++/39205] New: Warning when object syntax is used to call a static member function

2009-02-16 Thread pgrealis at yahoo-inc dot com
I can't think of a scenario where one would want to write x.f() over X::f()
when f() is static.  I'd like a warning for this so I can catch with -Werror.

% g++ --version
g++ (GCC) 3.4.5 20051201 (Red Hat 3.4.5-2)
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

% uname -a
Linux norway.corp.ukl.yahoo.com 2.6.9-34.ELsmp #1 SMP Fri Feb 24 16:56:28 EST
2006 x86_64 x86_64 x86_64 GNU/Linux


cat t1.cpp
struct X
{
void foo() {}
static void bar() {}
};

int main()
{
  X x;
  x.foo();
  X::bar();
  x.bar(); // *** I'd like a warning for this ***
}

g++ t1.cpp


-- 
   Summary: Warning when object syntax is used to call a static
member function
   Product: gcc
   Version: 3.4.5
Status: UNCONFIRMED
  Severity: enhancement
  Priority: P3
 Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
    ReportedBy: pgrealis at yahoo-inc dot com


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



[Bug c++/39205] Warning when object syntax is used to call a static member function

2009-02-17 Thread pgrealis at yahoo-inc dot com


--- Comment #3 from pgrealis at yahoo-inc dot com  2009-02-17 11:20 ---
(In reply to comment #1)
> This is perfectly valid C++.

I never claimed anything different.  Is your argument that no warning should be
issued for "perfectly valid C++"?

"(int)1.5" is perfectly valid C++, yet -Wold-style-cast will emit a warning for
its use.

To close as INVALID, please refute the following:
> I can't think of a scenario where one would want to write x.f() over X::f()
> when f() is static.


-- 

pgrealis at yahoo-inc dot com changed:

   What|Removed |Added

     CC|                |pgrealis at yahoo-inc dot
       ||com
 Status|RESOLVED|UNCONFIRMED
 Resolution|INVALID |


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