public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/53863] New: misleading error message for redefinitions
@ 2012-07-05 10:21 akim.demaille at gmail dot com
  2012-07-05 10:46 ` [Bug c++/53863] " redi at gcc dot gnu.org
  2021-07-16 14:50 ` redi at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: akim.demaille at gmail dot com @ 2012-07-05 10:21 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 53863
           Summary: misleading error message for redefinitions
    Classification: Unclassified
           Product: gcc
           Version: 4.7.1
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: akim.demaille@gmail.com


Hi,

In my opinion gcc provides a clearer error than g++ does.

$ cat fo.c
enum { a = 1 };
enum { a = 1 };
$ gcc-mp-4.7 -Wall /tmp/fo.c
/tmp/fo.c:2:8: error: redeclaration of enumerator 'a'
/tmp/fo.c:1:8: note: previous definition of 'a' was here
$ g++-mp-4.7 -Wall /tmp/fo.c
/tmp/fo.c:2:12: error: conflicting declaration 'a'
/tmp/fo.c:1:8: error: 'a' has a previous declaration as '<anonymous enum> a'

(also, shouldn't it be about "definition" instead of "declaration"?
gcc has "previous definition" but "redeclaration", while g++ has "declaration"
twice)

Thanks for GCC!


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

* [Bug c++/53863] misleading error message for redefinitions
  2012-07-05 10:21 [Bug c++/53863] New: misleading error message for redefinitions akim.demaille at gmail dot com
@ 2012-07-05 10:46 ` redi at gcc dot gnu.org
  2021-07-16 14:50 ` redi at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2012-07-05 10:46 UTC (permalink / raw)
  To: gcc-bugs

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

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> 2012-07-05 10:45:51 UTC ---
In the words of the C++ standard "a = 1" is an "enumerator-definition", which
declares the name "a"

(EDG says declaration for C and C++, Clang says definition for C and C++)

I think the reason for the G++ wording is that the same diagnostic is used in
this case:

extern int a;
extern long a;

t.cc:2:13: error: conflicting declaration 'long int a'
t.cc:1:12: error: 'a' has a previous declaration as 'int a'

And in this case they are declarations, not definitions.

Interestingly the C front end gives a different diagnostic here, changing
"definition" to "declaration"

t.c:2:13: error: conflicting types for 'a'
t.c:1:12: note: previous declaration of 'a' was here


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

* [Bug c++/53863] misleading error message for redefinitions
  2012-07-05 10:21 [Bug c++/53863] New: misleading error message for redefinitions akim.demaille at gmail dot com
  2012-07-05 10:46 ` [Bug c++/53863] " redi at gcc dot gnu.org
@ 2021-07-16 14:50 ` redi at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2021-07-16 14:50 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2021-07-16

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Current trunk says this:

53863.C:2:12: error: 'a' conflicts with a previous declaration
    2 | enum { a = 1 };
      |            ^
53863.C:1:8: note: previous declaration '<unnamed enum> a'
    1 | enum { a = 1 };
      |        ^

The caret on the error seems wrong, as it points to the initializer not the
enumerator. The note is correct.

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

end of thread, other threads:[~2021-07-16 14:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-05 10:21 [Bug c++/53863] New: misleading error message for redefinitions akim.demaille at gmail dot com
2012-07-05 10:46 ` [Bug c++/53863] " redi at gcc dot gnu.org
2021-07-16 14: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).