llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

Incorrect interaction of decltype with `operator<<`

Open ojrosten opened this issue 7 years ago • 1 comments

Bugzilla Link 40475
Version unspecified
OS MacOS X
CC @DougGregor,@zygoloid

Extended Description

I'm running clang-1000.11.45.5 on my mac. To my bafflement, the following snippet compiles and runs, producing "Hello, world!":

struct foo
{
};

decltype(std::stringstream{} << foo{}) f{"Hello, world!"};

//f << foo{};

std::cout << f.str() << '\n';

Reinstating the commented line does at least give the expected compilation error since no appropriate operator<< exists.

As far as I can tell, the problem seems specific to mac.

ojrosten avatar Jan 26 '19 09:01 ojrosten

This is LWG1203.

Fixed by commit c90dee1e90045feb039be640864f038eebd1d8cd in LLVM 12.

frederick-vs-ja avatar Jan 13 '25 01:01 frederick-vs-ja