[cfe-dev] No diagnostic for C++03 14.6.4.2 ?

Sean McBride sean at rogue-research.com
Thu Nov 14 14:50:03 PST 2013


Hi all,

I'm not a language lawyer, but consider:

----------------------
#include <stdio.h>

static void PrintIt(double value)
{
  printf("value is %f \n", value);
}

template <class T>
void Function(T *value)
{
  PrintIt(*value);
}

int main ()
{
  int x = 1;
  Function(&x);

  short y = 2;
  Function(&y);

  return x + y;
}
----------------------

clang -std=c++03 -pedantic -Weverything test.cxx 

gives no warning/error.  C++03 14.6.4.2 seems to say that, since PrintIt() is static, it should not be found.  xlc generates an error:

  *The name lookup for "PrintIt" did not find a declaration.
  *Static declarations are not considered for a function call if the function is not qualified.

Shouldn't clang be producing a diagnostic here?

(If I remove the static, clang's -Wmissing-prototypes complains; and if I add the static, xlc complains.)

Thanks,

-- 
____________________________________________________________
Sean McBride, B. Eng                 sean at rogue-research.com
Rogue Research                        www.rogue-research.com 
Mac Software Developer              Montréal, Québec, Canada






More information about the cfe-dev mailing list