public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/50871] New: [C++0x] G++ fails to reject explicitly-defaulted function definition with different exception spec
@ 2011-10-25 22:29 redi at gcc dot gnu.org
  2011-10-26 10:15 ` [Bug c++/50871] [C++0x] G++ fails to reject explicitly-defaulted function definition with different exception spec in system headers paolo.carlini at oracle dot com
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: redi at gcc dot gnu.org @ 2011-10-25 22:29 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50871

             Bug #: 50871
           Summary: [C++0x] G++ fails to reject explicitly-defaulted
                    function definition with different exception spec
    Classification: Unclassified
           Product: gcc
           Version: 4.6.1
            Status: UNCONFIRMED
          Keywords: accepts-invalid
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: redi@gcc.gnu.org


Preprocessed source, note first line:

# 1 "/" 3

class condvar
{
public:

  condvar() noexcept;
  ~condvar() noexcept;

};

condvar::condvar() = default;
condvar::~condvar() = default;


This should be rejected because the explicitily-defaulted definitions are
missing "noexcept" but it compiles without error:

$ g++ -std=gnu++0x  cv.ii -c
$


If the first line is removed it is rejected:

cv.ii:11:18: error: declaration of ‘condvar::condvar()’ has a different
exception specifier
cv.ii:6:3: error: from previous declaration ‘condvar::condvar() noexcept
(true)’
cv.ii:12:19: error: declaration of ‘condvar::~condvar()’ has a different
exception specifier
cv.ii:7:3: error: from previous declaration ‘condvar::~condvar() noexcept
(true)’


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

* [Bug c++/50871] [C++0x] G++ fails to reject explicitly-defaulted function definition with different exception spec in system headers
  2011-10-25 22:29 [Bug c++/50871] New: [C++0x] G++ fails to reject explicitly-defaulted function definition with different exception spec redi at gcc dot gnu.org
@ 2011-10-26 10:15 ` paolo.carlini at oracle dot com
  2011-10-26 10:41 ` redi at gcc dot gnu.org
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-10-26 10:15 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50871

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org

--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-10-26 10:14:55 UTC ---
Well, the error itself is protected by ! DECL_IN_SYSTEM_HEADER (old_decl). Thus
I guess the point is whether we want to do something special for C++11 here,
like errors involving defaulted definitions or noexcept itself. Maybe Jason has
something to suggest..


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

* [Bug c++/50871] [C++0x] G++ fails to reject explicitly-defaulted function definition with different exception spec in system headers
  2011-10-25 22:29 [Bug c++/50871] New: [C++0x] G++ fails to reject explicitly-defaulted function definition with different exception spec redi at gcc dot gnu.org
  2011-10-26 10:15 ` [Bug c++/50871] [C++0x] G++ fails to reject explicitly-defaulted function definition with different exception spec in system headers paolo.carlini at oracle dot com
@ 2011-10-26 10:41 ` redi at gcc dot gnu.org
  2011-10-26 11:31 ` paolo.carlini at oracle dot com
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: redi at gcc dot gnu.org @ 2011-10-26 10:41 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50871

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-10-26 10:40:30 UTC ---
Ah of course it's a system header thing, but -pedantic would have caught it.

This let a bug slip through in the library, which I fixed with
http://gcc.gnu.org/viewcvs/trunk/libstdc%2B%2B-v3/src/condition_variable.cc?r1=180454&r2=180453&pathrev=180454 
It would be nice if the compiler had caught it. I assume the condition is there
to handle badly-written system headers, but I don't think we want to allow
mismatched exception spec in libstdc++ itself.


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

* [Bug c++/50871] [C++0x] G++ fails to reject explicitly-defaulted function definition with different exception spec in system headers
  2011-10-25 22:29 [Bug c++/50871] New: [C++0x] G++ fails to reject explicitly-defaulted function definition with different exception spec redi at gcc dot gnu.org
  2011-10-26 10:15 ` [Bug c++/50871] [C++0x] G++ fails to reject explicitly-defaulted function definition with different exception spec in system headers paolo.carlini at oracle dot com
  2011-10-26 10:41 ` redi at gcc dot gnu.org
@ 2011-10-26 11:31 ` paolo.carlini at oracle dot com
  2011-10-26 13:38 ` jason at gcc dot gnu.org
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-10-26 11:31 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50871

--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-10-26 11:31:07 UTC ---
I know. -pedantic works indeed. Really, changing this would be easy, if we
wanted, maybe it's just something from the past? Jason should know...


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

* [Bug c++/50871] [C++0x] G++ fails to reject explicitly-defaulted function definition with different exception spec in system headers
  2011-10-25 22:29 [Bug c++/50871] New: [C++0x] G++ fails to reject explicitly-defaulted function definition with different exception spec redi at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2011-10-26 11:31 ` paolo.carlini at oracle dot com
@ 2011-10-26 13:38 ` jason at gcc dot gnu.org
  2011-10-26 13:47 ` redi at gcc dot gnu.org
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: jason at gcc dot gnu.org @ 2011-10-26 13:38 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50871

--- Comment #4 from Jason Merrill <jason at gcc dot gnu.org> 2011-10-26 13:37:23 UTC ---
Are the libstdc++ headers treated as system headers when building the library
itself?  If so, that seems like the thing to fix.


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

* [Bug c++/50871] [C++0x] G++ fails to reject explicitly-defaulted function definition with different exception spec in system headers
  2011-10-25 22:29 [Bug c++/50871] New: [C++0x] G++ fails to reject explicitly-defaulted function definition with different exception spec redi at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2011-10-26 13:38 ` jason at gcc dot gnu.org
@ 2011-10-26 13:47 ` redi at gcc dot gnu.org
  2011-10-27 13:17 ` paolo.carlini at oracle dot com
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: redi at gcc dot gnu.org @ 2011-10-26 13:47 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50871

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-10-26 13:46:45 UTC ---
Yes they are. Not doing that would be a good idea


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

* [Bug c++/50871] [C++0x] G++ fails to reject explicitly-defaulted function definition with different exception spec in system headers
  2011-10-25 22:29 [Bug c++/50871] New: [C++0x] G++ fails to reject explicitly-defaulted function definition with different exception spec redi at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2011-10-26 13:47 ` redi at gcc dot gnu.org
@ 2011-10-27 13:17 ` paolo.carlini at oracle dot com
  2011-10-27 13:31 ` redi at gcc dot gnu.org
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-10-27 13:17 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50871

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |paolo.carlini at oracle dot
                   |                            |com

--- Comment #6 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-10-27 13:17:15 UTC ---
Couldn't we start on this by simply building the library with -pedantic? I
think this something we can di now, and would have catched a similar thinko of
mine a couple of weeks ago


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

* [Bug c++/50871] [C++0x] G++ fails to reject explicitly-defaulted function definition with different exception spec in system headers
  2011-10-25 22:29 [Bug c++/50871] New: [C++0x] G++ fails to reject explicitly-defaulted function definition with different exception spec redi at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2011-10-27 13:17 ` paolo.carlini at oracle dot com
@ 2011-10-27 13:31 ` redi at gcc dot gnu.org
  2011-10-27 13:35 ` paolo.carlini at oracle dot com
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: redi at gcc dot gnu.org @ 2011-10-27 13:31 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50871

--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-10-27 13:31:17 UTC ---
It would work for my original case, yes.  There are other cases where the
warning is not a pedwarn, but is just suppressed by system_header while
building the lib.

But it occurred to me that we currently rely on system_header to suppress
warnings about using variadic templates in c++98 mode


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

* [Bug c++/50871] [C++0x] G++ fails to reject explicitly-defaulted function definition with different exception spec in system headers
  2011-10-25 22:29 [Bug c++/50871] New: [C++0x] G++ fails to reject explicitly-defaulted function definition with different exception spec redi at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2011-10-27 13:31 ` redi at gcc dot gnu.org
@ 2011-10-27 13:35 ` paolo.carlini at oracle dot com
  2011-11-10 22:50 ` [Bug libstdc++/50871] " jason at gcc dot gnu.org
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-10-27 13:35 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50871

--- Comment #8 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-10-27 13:34:31 UTC ---
Yes, and I'm afraid we rely on it even more, not something we can do today.


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

* [Bug libstdc++/50871] [C++0x] G++ fails to reject explicitly-defaulted function definition with different exception spec in system headers
  2011-10-25 22:29 [Bug c++/50871] New: [C++0x] G++ fails to reject explicitly-defaulted function definition with different exception spec redi at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2011-10-27 13:35 ` paolo.carlini at oracle dot com
@ 2011-11-10 22:50 ` jason at gcc dot gnu.org
  2011-12-03 15:35 ` redi at gcc dot gnu.org
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: jason at gcc dot gnu.org @ 2011-11-10 22:50 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50871

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c++                         |libstdc++

--- Comment #9 from Jason Merrill <jason at gcc dot gnu.org> 2011-11-10 22:01:14 UTC ---
Changing component.


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

* [Bug libstdc++/50871] [C++0x] G++ fails to reject explicitly-defaulted function definition with different exception spec in system headers
  2011-10-25 22:29 [Bug c++/50871] New: [C++0x] G++ fails to reject explicitly-defaulted function definition with different exception spec redi at gcc dot gnu.org
                   ` (8 preceding siblings ...)
  2011-11-10 22:50 ` [Bug libstdc++/50871] " jason at gcc dot gnu.org
@ 2011-12-03 15:35 ` redi at gcc dot gnu.org
  2014-04-04 17:06 ` redi at gcc dot gnu.org
  2014-06-24 15:00 ` redi at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: redi at gcc dot gnu.org @ 2011-12-03 15:35 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50871

--- Comment #10 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-12-03 15:34:53 UTC ---
It occurs to me we could use a diagnostic pragma to disable warnings about
variadic templates in our headers, instead of marking them as system headers.
That wouldn't work currently because the variadic templates warning is [enabled
by default] so there's no option to disable it.


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

* [Bug libstdc++/50871] [C++0x] G++ fails to reject explicitly-defaulted function definition with different exception spec in system headers
  2011-10-25 22:29 [Bug c++/50871] New: [C++0x] G++ fails to reject explicitly-defaulted function definition with different exception spec redi at gcc dot gnu.org
                   ` (9 preceding siblings ...)
  2011-12-03 15:35 ` redi at gcc dot gnu.org
@ 2014-04-04 17:06 ` redi at gcc dot gnu.org
  2014-06-24 15:00 ` redi at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: redi at gcc dot gnu.org @ 2014-04-04 17:06 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50871

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2014-04-04
           Assignee|unassigned at gcc dot gnu.org      |redi at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #11 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This bug hides the fact that we've apparently always been missing exception
specs on the operator== and operator!= for std::allocator.

Clang noticed this:

/home/jwakely/src/gcc/gcc/libstdc++-v3/testsuite/20_util/headers/memory/synopsis.cc:27:8:
error: exception specification in declaration does not match previous
declaration
/home/jwakely/src/gcc/gcc/libstdc++-v3/testsuite/20_util/headers/memory/synopsis.cc:29:8:
error: exception specification in declaration does not match previous
declaration
2 errors generated.

I'll look into using -pedantic when building the library and maybe for some of
the testsuite.


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

* [Bug libstdc++/50871] [C++0x] G++ fails to reject explicitly-defaulted function definition with different exception spec in system headers
  2011-10-25 22:29 [Bug c++/50871] New: [C++0x] G++ fails to reject explicitly-defaulted function definition with different exception spec redi at gcc dot gnu.org
                   ` (10 preceding siblings ...)
  2014-04-04 17:06 ` redi at gcc dot gnu.org
@ 2014-06-24 15:00 ` redi at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: redi at gcc dot gnu.org @ 2014-06-24 15:00 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |NEW
           Assignee|redi at gcc dot gnu.org            |unassigned at gcc dot gnu.org

--- Comment #12 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I've tried adding -Wpedantic to the WARN_FLAGS used to build libstdc++, but it
produces a lot of noise due to the use of extern/inline explicit instantiations
for templates, some of which are in .cc files not headers, so don't benefit
from -Wsystem-headers.

Unlike -Wno-long-long and -Wno-variadic-macros (both needed to stop too many
pedantic warnings) I don't think there's any way to use -Wpedantic without
getting warnings about the extern templates.  We could move the affected
sources from src/c++98/ to src/c++11/ and compile as C++11 but that's probably
a bigger change than we want to do right now.

So I'm just going to try to remember to occassionally build using
  --enable-cxx-flags="-Wpedantic -Wno-long-long -Wno-variadic-macros" 
and check there are no new problems.


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

end of thread, other threads:[~2014-06-24 15:00 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-25 22:29 [Bug c++/50871] New: [C++0x] G++ fails to reject explicitly-defaulted function definition with different exception spec redi at gcc dot gnu.org
2011-10-26 10:15 ` [Bug c++/50871] [C++0x] G++ fails to reject explicitly-defaulted function definition with different exception spec in system headers paolo.carlini at oracle dot com
2011-10-26 10:41 ` redi at gcc dot gnu.org
2011-10-26 11:31 ` paolo.carlini at oracle dot com
2011-10-26 13:38 ` jason at gcc dot gnu.org
2011-10-26 13:47 ` redi at gcc dot gnu.org
2011-10-27 13:17 ` paolo.carlini at oracle dot com
2011-10-27 13:31 ` redi at gcc dot gnu.org
2011-10-27 13:35 ` paolo.carlini at oracle dot com
2011-11-10 22:50 ` [Bug libstdc++/50871] " jason at gcc dot gnu.org
2011-12-03 15:35 ` redi at gcc dot gnu.org
2014-04-04 17:06 ` redi at gcc dot gnu.org
2014-06-24 15:00 ` redi 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).