public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/66537] New: An explicit default constructor is accepted when initializing from empty braces
@ 2015-06-14 17:11 ville.voutilainen at gmail dot com
  2015-06-14 20:05 ` [Bug c++/66537] " daniel.kruegler at googlemail dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: ville.voutilainen at gmail dot com @ 2015-06-14 17:11 UTC (permalink / raw)
  To: gcc-bugs

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.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/66537] An explicit default constructor is accepted when initializing from empty braces
  2015-06-14 17:11 [Bug c++/66537] New: An explicit default constructor is accepted when initializing from empty braces ville.voutilainen at gmail dot com
@ 2015-06-14 20:05 ` daniel.kruegler at googlemail dot com
  2015-06-15  9:12 ` ville.voutilainen at gmail dot com
  2015-06-15 16:03 ` [Bug c++/66537] [DR 1518] " jason at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2015-06-14 20:05 UTC (permalink / raw)
  To: gcc-bugs

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

Daniel Krügler <daniel.kruegler at googlemail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |daniel.kruegler@googlemail.
                   |                            |com

--- Comment #1 from Daniel Krügler <daniel.kruegler at googlemail dot com> ---
Isn't that similar to bug 54835? As far as I remember Jason interprets the
standard that the code should be valid, see his comments in above mentioned
issue.
>From gcc-bugs-return-488968-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sun Jun 14 20:12:37 2015
Return-Path: <gcc-bugs-return-488968-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 34691 invoked by alias); 14 Jun 2015 20:12:36 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 34670 invoked by uid 48); 14 Jun 2015 20:12:32 -0000
From: "ville.voutilainen at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/66537] An explicit default constructor is accepted when initializing from empty braces
Date: Sun, 14 Jun 2015 20:12:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: 6.0
X-Bugzilla-Keywords: accepts-invalid
X-Bugzilla-Severity: normal
X-Bugzilla-Who: ville.voutilainen at gmail dot com
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Resolution:
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-66537-4-AVRGonmABy@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-66537-4@http.gcc.gnu.org/bugzilla/>
References: <bug-66537-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-06/txt/msg01300.txt.bz2
Content-length: 660

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

--- Comment #2 from Ville Voutilainen <ville.voutilainen at gmail dot com> ---
(In reply to Daniel Krügler from comment #1)
> Isn't that similar to bug 54835? As far as I remember Jason interprets the
> standard that the code should be valid, see his comments in above mentioned
> issue.

I think there's a difference. The _temporary_ initialized from {}
is expected to not be allowed when the default constructor is explicit. What
happens after that in returning from a function or passing an argument
is separate.

Implementations disagree, so perhaps the specification needs to be clarified.
>From gcc-bugs-return-488969-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sun Jun 14 20:28:11 2015
Return-Path: <gcc-bugs-return-488969-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 59214 invoked by alias); 14 Jun 2015 20:28:11 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 59159 invoked by uid 48); 14 Jun 2015 20:28:07 -0000
From: "rusty at rustcorp dot com.au" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/66425] (void) cast doesn't suppress __attribute__((warn_unused_result))
Date: Sun, 14 Jun 2015 20:28:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c
X-Bugzilla-Version: 4.9.2
X-Bugzilla-Keywords:
X-Bugzilla-Severity: enhancement
X-Bugzilla-Who: rusty at rustcorp dot com.au
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Resolution:
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-66425-4-fqiRJuqSEX@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-66425-4@http.gcc.gnu.org/bugzilla/>
References: <bug-66425-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-06/txt/msg01301.txt.bz2
Content-length: 704

https://gcc.gnu.org/bugzilla/show_bug.cgi?idf425

--- Comment #19 from rusty at rustcorp dot com.au ---
I like WUR as a sanity-check, and it is useful that more and more library
authors are using it (generally quite well).  As Andrew points out, this has
taken 10 years!  The downside is that false positives are becoming more common.

For example, gnulib also includes a routine to handle this, since 2008:

http://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob;f=lib/ignore-value.h;hh521edb38f50cb2230c8560a125864be212db6a;hb=HEAD

I believe that changing conditions call for a re-evaluation.  And yes, I'd like
to see a comment on any cast-to-void, not just for WUR.

Thanks for your patience!


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/66537] An explicit default constructor is accepted when initializing from empty braces
  2015-06-14 17:11 [Bug c++/66537] New: An explicit default constructor is accepted when initializing from empty braces ville.voutilainen at gmail dot com
  2015-06-14 20:05 ` [Bug c++/66537] " daniel.kruegler at googlemail dot com
@ 2015-06-15  9:12 ` ville.voutilainen at gmail dot com
  2015-06-15 16:03 ` [Bug c++/66537] [DR 1518] " jason at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: ville.voutilainen at gmail dot com @ 2015-06-15  9:12 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Ville Voutilainen <ville.voutilainen at gmail dot com> ---
Oh well, I guess CWG 1518 as referenced in the other bug should solve this.
I'm fine either way, if explicit default constructors are decided to
work with the example, we can close this bug as invalid, and I should pursue
harder making library tag types non-default-constructible.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/66537] [DR 1518] An explicit default constructor is accepted when initializing from empty braces
  2015-06-14 17:11 [Bug c++/66537] New: An explicit default constructor is accepted when initializing from empty braces ville.voutilainen at gmail dot com
  2015-06-14 20:05 ` [Bug c++/66537] " daniel.kruegler at googlemail dot com
  2015-06-15  9:12 ` ville.voutilainen at gmail dot com
@ 2015-06-15 16:03 ` jason at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: jason at gcc dot gnu.org @ 2015-06-15 16:03 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |jason at gcc dot gnu.org
         Resolution|---                         |DUPLICATE
            Summary|An explicit default         |[DR 1518] An explicit
                   |constructor is accepted     |default constructor is
                   |when initializing from      |accepted when initializing
                   |empty braces                |from empty braces

--- Comment #4 from Jason Merrill <jason at gcc dot gnu.org> ---
This seems the same as 54835.

*** This bug has been marked as a duplicate of bug 54835 ***


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-06-15 16:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-14 17:11 [Bug c++/66537] New: An explicit default constructor is accepted when initializing from empty braces ville.voutilainen at gmail dot com
2015-06-14 20:05 ` [Bug c++/66537] " daniel.kruegler at googlemail dot com
2015-06-15  9:12 ` ville.voutilainen at gmail dot com
2015-06-15 16:03 ` [Bug c++/66537] [DR 1518] " jason at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).