[cfe-dev] Bug 18275 - Incorrect const qualifier behavior in definition.

suyog sarda sardask01 at gmail.com
Wed Feb 19 12:52:23 PST 2014

Thanks Richard for the review. Even i felt that cv qualifier checking and
setting is not suitable (though the standard 13.1/3 is specifically related
to CV qualifiers). Earlier i was checking CV qualifiers and setting type,
which obviously failed for function templates. And i agree to your point
that if the parameter is not dependent then set the type as in instantiated

In that case, do we still need to check if the parameters are CV qualified
alongwith checking if parameter is dependent? I am attaching a patch where
we do not check if the parameters are CV qualified but only checks if it is
not dependent and then set the type. This patch works for the test case in
the bug with no regression. Also, if we are not checking CV qualifiers and
just checking only dependent type then is it feasible to put comment
regarding standard 13.1/3? How should comment look if above patch is fine.

Also, i am pasting test case from the bug itself. Please let me know which
file to put it in. I cannot think of a negative test case for this bug.

Your help is greatly appreciated.

Test case :

*struct B
    void f(const int);

void B::f(int x)
    x = 0;

void f()
    B b;

On Wed, Feb 19, 2014 at 12:26 AM, Richard Smith <metafoo at gmail.com> wrote:

> This patch needs testcases.
> Also, the way in which you're updating the type of the parameter doesn't
> look correct -- there's no reason to think that the qualifiers will be
> local.
> We discussed cases like this at the WG21 meeting in Issaquah last week,
> and decided that cv-stripping should *not* be applied to dependent
> parameter types when determining whether two function templates are
> redeclarations. Therefore:
>   template<typename T> void f(T);
>   template<typename T> void f(const T);
> ... are not redeclarations (because, for instance, they have different
> parameter types when T = int[]).
> That makes this problem easier to fix: if the parameter type within
> PatternDecl is not dependent, set the type of the parameter in the
> instantiated function to that type. Otherwise, leave it alone, since we
> already know it will match.
> On Tue Feb 18 2014 at 6:02:55 AM, suyog sarda <sardask01 at gmail.com> wrote:
>> Gentle Ping !! Please help in reviewing the patch for bug 18275.
>> --
>> With regards,
>> Suyog Sarda

With regards,
Suyog Sarda
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140220/573687e5/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PR_18275.patch
Type: text/x-patch
Size: 1203 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140220/573687e5/attachment.bin>

More information about the cfe-commits mailing list