public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/96183] GCC accepts "convert '<throw-expression>' from 'void' to 'int'" at compile time
Date: Thu, 22 Jul 2021 14:02:27 +0000	[thread overview]
Message-ID: <bug-96183-4-fzcIogDqIE@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-96183-4@http.gcc.gnu.org/bugzilla/>

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2021-07-22
             Status|UNCONFIRMED                 |NEW
           Keywords|accepts-invalid             |diagnostic
     Ever confirmed|0                           |1

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The 'auto' parameter makes this a function template, and you never instantiate
the template. Compilers are not required to diagnose errors in uninstantiated
templates.

If you call it, you get the expected error:

void 
foo (auto,
    int var = throw )
{}

int main()
{
  foo(1);
}


96183.C: In function ‘void foo(auto:1, int) [with auto:1 = int]’:
96183.C:3:15: error: could not convert ‘<throw-expression>’ from ‘void’ to
‘int’
    3 |     int var = throw )
      |               ^~~~~
      |               |
      |               void
96183.C:8:6: note:   when instantiating default argument for call to ‘void
foo(auto:1, int) [with auto:1 = int]’
    8 |   foo(1);
      |   ~~~^~~
96183.C: In function ‘int main()’:
96183.C:8:6: error: void value not ignored as it ought to be

The second error seems bogus though.


Confirming as a diagnostic bug, but it's not accepts-invalid.

  reply	other threads:[~2021-07-22 14:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-13 12:24 [Bug c++/96183] New: " haoxintu at gmail dot com
2021-07-22 14:02 ` redi at gcc dot gnu.org [this message]
2021-12-14  5:36 ` [Bug c++/96183] " pinskia at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-96183-4-fzcIogDqIE@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).