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

            Bug ID: 66537
           Summary: An explicit default constructor is accepted when
                    initializing from empty braces
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Keywords: accepts-invalid
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ville.voutilainen at gmail dot com
                CC: jason at redhat dot com
  Target Milestone: ---

Test snippet:

struct Bob
{
    explicit Bob() {}
};

Bob f() 
{
    return {}; // #1
}

void f2(Bob) {}

int main()
{
    f2({}); // #2
}

gcc accepts both #1 and #2, clang rejects both.

I have submitted a patch that makes the standard library tag types
non-default-constructible, but an alternative solution to certain kinds
of ambiguity problems with tuple would be to make the tag types' default
constructors explicit rather than suppressing them. That doesn't currently
work because the front-end accepts initializations like in the example above.

Reply via email to