Bug 53725 - Prototype does not match error if the definition of the ctor is separated from its declaration and attributes
Summary: Prototype does not match error if the definition of the ctor is separated fro...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.6.3
: P3 normal
Target Milestone: 6.0
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2012-06-19 23:46 UTC by tr3w
Modified: 2021-07-23 01:26 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2012-06-20 00:00:00


Attachments
Minimal example (166 bytes, text/plain)
2012-06-19 23:46 UTC, tr3w
Details

Note You need to log in before you can comment on or make changes to this bug.
Description tr3w 2012-06-19 23:46:53 UTC
Created attachment 27657 [details]
Minimal example

In certain conditions if the definition of the ctor separated from its declaration it generates an compiler error.

I created a minimal example. The original code is from Boost.Move.
Error:
testfull.cpp:16:1: error: prototype for ‘movable::movable(rv<movable>&)’ does not match any in class ‘movable’
testfull.cpp:5:7: error: candidates are: movable::movable(const movable&)
testfull.cpp:13:5: error:                 movable::movable(rv<movable>&)


If the ctor definition is inside the class the code compiles.

The same can happen with the assignment operator as visible here:
http://lists.boost.org/Archives/boost/2011/07/184263.php
Comment 1 Jonathan Wakely 2012-06-20 01:43:15 UTC
Confirmed.

The candidate list also includes the implicitly-declared copy ctor (and in c++11 mode the move ctor) which is also wrong because no definition can be provided for an implicitly-declared special member function.
Comment 2 Paolo Carlini 2014-06-11 18:06:14 UTC
Related to PR49377
Comment 3 Andrew Pinski 2021-07-23 01:20:21 UTC
Fixed in GCC 6.1.0