c++/1835: toplevel cv-qualifiers considered in finding best viable function

dbaron@fas.harvard.edu dbaron@fas.harvard.edu
Thu Feb 1 19:56:00 GMT 2001


>Number:         1835
>Category:       c++
>Synopsis:       toplevel cv-qualifiers considered in finding best viable function
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Thu Feb 01 19:56:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     L. David Baron
>Release:        trunk (2001-02-01) and older releases (e.g., 2.91.66)
>Organization:
>Environment:
RedHat 7.0, i386
>Description:
I think this testcase demonstrates the bug in
<URL: http://bugzilla.mozilla.org/show_bug.cgi?id=65664 >,
which is that the compiler is not considering C++ section
8.3.5, clause 3 (which is repeated in 13.1, clause 3),
which says that:

   After producing the list of parameter types, several
   transformations take place upon these types to determine
   the function type.  Any cv-qualifier modifying a
   parameter type is deleted; e.g., the type |void(const
   int)| becomes |void(int)|.  Such cv-qualifiers only
   affect the definition of the parameter within the body
   of the function; they do not affect the function type.

when it is applying the rule section 13.3.3.2, which says:

    Standard conversion sequence S1 is a better conversion
    sequence than standard conversion sequence S2 if
     ...
     * S1 and S2 differ only in their qualification
       conversion and yield similar types T1 and T2 (4.4),
       respectively, and the cv-qualification signature of
       type T1 is a proper subset of the cv-qualification
       signature of type T2.

In other words, I think this testcase is correct and should
return 0, but when compiled with `g++ -pedantic` it gives
the error:

call of overloaded `f(int*&, int*&)' is ambiguous
candidates are: int f(void*, int*)
                int f(int*, const int*)

The testcase is:
-----
inline int f(void *p, int *q)
{
  return 1;
}

inline int f(int *p, const int *q)
{
  return 0;
}

int main()
{
  int *a = 0;
  
  return f(a, a);// This should choose int f(int*,const int*)
}
-----
>How-To-Repeat:
Compile testcase with 'g++ -pedantic'
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the Gcc-bugs mailing list