[LLVMbugs] [Bug 21425] New: conversion string to char claims it's void

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Oct 31 02:14:40 PDT 2014


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

            Bug ID: 21425
           Summary: conversion string to char claims it's void
           Product: clang
           Version: 3.4
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: akim.demaille at gmail.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

The following piece of code (which is stupid, of course), produces an
unexpected error message about "void" instead of "std::string".

$ cat foo.cc
#include <string>

char c = char{std::string("foo")};

$ clang++-mp-3.5 --version
clang version 3.5.0 (branches/release_35 216817)
Target: x86_64-apple-darwin13.4.0
Thread model: posix

$ clang++-mp-3.5 -c foo.cc -std=c++11
foo.cc:3:10: error: no viable conversion from 'void' to 'char'
char c = char{std::string("foo")};
         ^   ~~~~~~~~~~~~~~~~~~~~
1 error generated.


Or more generally:

$ cat foo.cc
struct foo{};
int c = int{foo{}};


$ clang++-mp-3.5 -c foo.cc -std=c++11
foo.cc:2:9: error: no viable conversion from 'void' to 'int'
int c = int{foo{}};
        ^  ~~~~~~~
1 error generated.


$ g++-mp-4.9 -std=c++11 -c foo.cc
foo.cc:2:18: error: cannot convert 'foo' to 'int' in initialization
 int c = int{foo{}};
                  ^

-- 
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/20141031/f2764b11/attachment.html>


More information about the llvm-bugs mailing list