public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/67113] New: unintelligent error message "only declarations of constructors can be 'explicit'" in cpp file's constructor define.
@ 2015-08-04 10:43 robinh3123 at gmail dot com
  2015-08-04 11:47 ` [Bug c++/67113] " redi at gcc dot gnu.org
  2015-08-04 11:50 ` redi at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: robinh3123 at gmail dot com @ 2015-08-04 10:43 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 67113
           Summary: unintelligent error message "only declarations of
                    constructors can be 'explicit'" in cpp file's
                    constructor define.
           Product: gcc
           Version: 4.9.2
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: robinh3123 at gmail dot com
  Target Milestone: ---

For the following codes (in 3 files):

$ cat a.cpp
#include "a.h"

int A::f()
{
        return n+1;
}

explicit A::A(int _n)   // <=== error at this line
{
        n = _n;
}



$ cat  a.h
class A
{
public:
        int n;
        int f();
        explicit A(int _n);
};



$ cat main.cpp
#include <iostream>
#include "a.h"  // for class A

using namespace std;

int main()
{
        A a(5);
        int i = a.f();
        cout << i << endl;
    return 0;
}


The compiler reports error message:
a.cpp:8:21: error: only declarations of constructors can be 'explicit'
 explicit A::A(int _n)

This is misleading, since A::A is really a constructor.
The error message should be something similar to:
     extra explicit before function A::A


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

* [Bug c++/67113] unintelligent error message "only declarations of constructors can be 'explicit'" in cpp file's constructor define.
  2015-08-04 10:43 [Bug c++/67113] New: unintelligent error message "only declarations of constructors can be 'explicit'" in cpp file's constructor define robinh3123 at gmail dot com
@ 2015-08-04 11:47 ` redi at gcc dot gnu.org
  2015-08-04 11:50 ` redi at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2015-08-04 11:47 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The diagnostic is technically correct (the best kind of correct!) because that
is a definition of a constructor, not just a declaration.

i.e. you are focusing on the word constructors and saying "but it is a
constructor!" when you should be focusing on "declarations of constructors".


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

* [Bug c++/67113] unintelligent error message "only declarations of constructors can be 'explicit'" in cpp file's constructor define.
  2015-08-04 10:43 [Bug c++/67113] New: unintelligent error message "only declarations of constructors can be 'explicit'" in cpp file's constructor define robinh3123 at gmail dot com
  2015-08-04 11:47 ` [Bug c++/67113] " redi at gcc dot gnu.org
@ 2015-08-04 11:50 ` redi at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2015-08-04 11:50 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |FIXED
   Target Milestone|---                         |5.0

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This is already fixed anyway, gcc 5 says:

a.cc:5:15: error: ‘explicit’ outside class declaration
>From gcc-bugs-return-494047-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Aug 04 11:51:46 2015
Return-Path: <gcc-bugs-return-494047-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 33183 invoked by alias); 4 Aug 2015 11:51:46 -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 33149 invoked by uid 48); 4 Aug 2015 11:51:42 -0000
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/67114] [MinGW64] build failure with POSIX threads enabled
Date: Tue, 04 Aug 2015 11:51:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: libstdc++
X-Bugzilla-Version: 5.2.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: redi at gcc dot gnu.org
X-Bugzilla-Status: NEW
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: bug_status cf_reconfirmed_on everconfirmed
Message-ID: <bug-67114-4-NtdxDbuCwG@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-67114-4@http.gcc.gnu.org/bugzilla/>
References: <bug-67114-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-08/txt/msg00189.txt.bz2
Content-length: 671

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-08-04
     Ever confirmed|0                           |1

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The problem is real, but obviously this patch is not acceptable because you
would need to add pthread_less to every implementation of pthreads, and to the
POSIX standard. GCC doesn't only support mingw.


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

end of thread, other threads:[~2015-08-04 11:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-04 10:43 [Bug c++/67113] New: unintelligent error message "only declarations of constructors can be 'explicit'" in cpp file's constructor define robinh3123 at gmail dot com
2015-08-04 11:47 ` [Bug c++/67113] " redi at gcc dot gnu.org
2015-08-04 11:50 ` 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).