This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/78244] New: Narrowing conversion is accepted in a function template, but it should be rejected


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78244

            Bug ID: 78244
           Summary: Narrowing conversion is accepted in a function
                    template, but it should be rejected
           Product: gcc
           Version: 6.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: michele.caini at gmail dot com
  Target Milestone: ---

Consider the following code:

    auto f() -> decltype(int{0.}, void()) { }
    int main() { f(); }

It fails to compile with the following error:

> narrowing conversion of '0.0' from 'double' to 'int' inside { }

On the other side, the following function is accepted:

    template <typename T>
    auto f(T) -> decltype(int{0.}, void()) { }

    int main(){
        f(0);
    }

Narrowing conversion still present.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]