[LLVMbugs] [Bug 21260] New: Default argument added afterwards to a function imported with using-statement won't be visible

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Oct 13 08:23:19 PDT 2014


http://llvm.org/bugs/show_bug.cgi?id=21260

            Bug ID: 21260
           Summary: Default argument added afterwards to a function
                    imported with using-statement won't be visible
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: tuomas.tynkkynen at iki.fi
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 13196
  --> http://llvm.org/bugs/attachment.cgi?id=13196&action=edit
First testcase.

With clang version 3.6.0 (trunk 219614) (llvm/trunk 219612), the following
doesn't compile, while several versions of g++ accept it.

////////////////
namespace A {
    int f(int x);
}

using A::f;

namespace A {
    int f(int x = 1);
}

int a = f();
////////////////

clang++ -std=c++11 default-param.cpp results in:

----------------
default-param.cpp:11:9: error: no matching function for call to 'f'
int a = f();
        ^
default-param.cpp:2:9: note: candidate function not viable: requires single
argument 'x', but no arguments were provided
    int f(int x);
        ^
1 error generated.
-----------------

i.e. even though a default argument was added afterwards to A::f, it's not
visible at ::f. N3485 section 8.3.6p9 (page 186) states:

When a declaration of a function is introduced by way of a using-declaration
(7.3.3), any default argument information associated with the declaration is
made known as well. If the function is redeclared thereafter in the namespace
with additional default arguments, the additional arguments are also known at
any point following the redeclaration where the using-declaration is in scope.

This suggests that clang's behaviour is wrong in this case. One different case
where clang also disagrees with GCC is array redeclarations with:

/////////
namespace A {
    extern int x[];
}

using A::x;

namespace A {
    int x[2];
}

constexpr unsigned long s = sizeof(x);
///////////

which results in

arr.cpp:11:35: error: invalid application of 'sizeof' to an incomplete type
'int []'
constexpr unsigned long s = sizeof(x);
                                  ^~~

I'm not sure what behaviour is correct in this case.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20141013/65657057/attachment.html>


More information about the llvm-bugs mailing list