LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 34912 - Brace-init of const type to non-const reference produces error message with missing/incorrect types
Summary: Brace-init of const type to non-const reference produces error message with m...
Status: RESOLVED FIXED
Alias: None
Product: clang
Classification: Unclassified
Component: C++14 (show other bugs)
Version: 4.0
Hardware: PC Linux
: P enhancement
Assignee: Unassigned Clang Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-10-10 20:25 PDT by Anthony Leedom
Modified: 2018-07-13 02:56 PDT (History)
2 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Anthony Leedom 2017-10-10 20:25:11 PDT
int main() {
    const int i{0};
    int& ref{i};
    return 0;
}


The above code produces the error message:

error: binding value of type 'void' to reference to type 'int' drops <<ERROR>> qualifiers
    int& ref{f.value};
         ^  ~~~~~~~~~

While the following produces the correct error message:

int main() {
    const int i{0};
    int& ref = i;
    return 0;
}

error: binding value of type 'const int' to reference to type 'int' drops 'const' qualifier
    int& ref = i;

Brace-initialization seems to cause an error in the error reporting, unable to access the correct types for the message to display. I'm not familiar with clang internals so I'm not much help here.
Comment 1 Nicolas Lesser 2018-07-13 02:56:28 PDT
This has been fixed in r336922, thanks! :)