[cfe-dev] Doubt on a couple of warnings on deleted functions

David Blaikie dblaikie at gmail.com
Mon Apr 21 07:47:48 PDT 2014


Yep
Both of these sound like bugs and should be able to be fixed just by
checking for a non-deleted definition. I'm not sure if there's a particular
function to test that.

The unused variable one might crop up in defaulted functions too, in which
case we'll want to check for a user provided definition.
On Apr 21, 2014 3:35 AM, "Nicola Gigante" <nicola.gigante at gmail.com> wrote:

> Hello.
>
> Consider this:
>
> $ cat example.cpp
> void func(int x) = delete;
> $ clang++ -std=c++11 -fsyntax-only -Wunused-parameter -Wmissing-prototypes
> example.cpp
> example.cpp:1:6: warning: no previous prototype for function 'func'
> [-Wmissing-prototypes]
> void func(int x) = delete;
>      ^
> example.cpp:1:15: warning: unused parameter 'x' [-Wunused-parameter]
> void func(int x) = delete;
>               ^
> 2 warnings generated.
>
> The two warnings seems false positives:
>
> 1) why does it warn about a missing prototype? One can't add a prototype
> because
> he'll get this error:
>
> error: deleted definition must be first declaration
> void func(int x) = delete;
>
> So, the deleted definition is acting like a prototype itself, doesn't it?
> I think the warning
> is wrong.
>
> 2) Does it make sense to warn about an unused parameter on a deleted
> definition?
> Of course is unused, but it can't be used anyway.
> This force the programmer to avoid parameters name, like:
> void func(int) = delete;
> but this can reduce readability and it seems to me there's no reason to
> force it.
>
> Note that these warnings pop up only on free functions. Deleted member
> functions
> don't generate these warnings in these cases.
>
> Does it make sense to fix these issues?
>
> This mail is a part of a more general effort of mine to be able to
> warning-less include
> (with -Weverything, more or less) the LLVM headers that I use in my
> project.
> I think (and hope) more will follow.
>
> Thanks,
> Nicola
> _______________________________________________
> 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/20140421/0d7a1881/attachment.html>


More information about the cfe-dev mailing list