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

Richard Smith richard at metafoo.co.uk
Thu Nov 14 17:30:17 PST 2013


On Thu, Nov 14, 2013 at 2:50 PM, Sean McBride <sean at rogue-research.com>wrote:

> 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?
>

This rule was changed by DR561:

http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#561

This has status CD2, which means "CD2: A DR issue not resolved in CD1 but
included in the Final Committee Draft advanced for balloting at the March,
2010 WG21 meeting." And DR means "DR: The full Committee has approved the
item as a proposed defect report.", as opposed to "Accepted: Like a DR
except that the issue concerns the wording of the current Working Paper
rather than that of the current International Standard."

That is, issue 561 was a defect in C++03 and the committee's intent was
that the language not work that way. Our "C++03" mode is ISO C++03 plus
defect reports, so includes this bug fix to C++03.


> (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
>
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20131114/a70220c0/attachment.html>


More information about the cfe-dev mailing list