[llvm-bugs] [Bug 28667] New: Invalid subexpression in sizeof fails to remove candidate

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Jul 22 09:44:46 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=28667

            Bug ID: 28667
           Summary: Invalid subexpression in sizeof fails to remove
                    candidate
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Keywords: accepts-invalid, compile-fail, miscompilation
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: hstong at ca.ibm.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
    Classification: Unclassified

In the following case, Clang fails to detect an error in the subexpression of
the sizeof during substitution of the template arguments into the signature of
the function in question.

Online compiler: http://melpon.org/wandbox/permlink/by24bjnKIvVPecSH

### SOURCE (<stdin>):
struct A { A(int); };

template <typename T> void foo(void *, char (*)[sizeof(0, A(T()))]) { }
template <typename T> void foo(int, ...);

int main(void) { foo<decltype(nullptr)>(0, 0); }


### COMPILER INVOCATION:
clang++ -cc1 -fsyntax-only -x c++ -std=c++11 -


### EXPECTED OUTPUT:
(clean compile)


### ACTUAL OUTPUT:
<stdin>:6:18: error: call to 'foo' is ambiguous
int main(void) { foo<decltype(nullptr)>(0, 0); }
                 ^~~~~~~~~~~~~~~~~~~~~~
<stdin>:3:28: note: candidate function [with T = nullptr_t]
template <typename T> void foo(void *, char (*)[sizeof(0, A(T()))]) { }
                           ^
<stdin>:4:28: note: candidate function [with T = nullptr_t]
template <typename T> void foo(int, ...);
                           ^
1 error generated.


### COMPILER VERSION INFO (clang++ -v):
clang version 4.0.0 (trunk 276290)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/llvm-head/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6.3
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64

-- 
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/20160722/019f0949/attachment.html>


More information about the llvm-bugs mailing list