public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/46765] New: Superfluous 'const' declaration does not generate error or warning
@ 2010-12-02 13:34 fredrik.hederstierna@securitas-direct.com
  2010-12-02 13:34 ` [Bug c/46765] " fredrik.hederstierna@securitas-direct.com
  2010-12-02 16:57 ` jsm28 at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: fredrik.hederstierna@securitas-direct.com @ 2010-12-02 13:34 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: Superfluous 'const' declaration does not generate
                    error or warning
           Product: gcc
           Version: 4.5.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: fredrik.hederstierna@securitas-direct.com


Assume we want to declare a pointer to constant data.
This can be done by e.g.

  int const *       ptrToConst1;

But C/C++ also accepts:

  //identical to: int const *       ptrToConst,
  const int *       ptrToConst2;

But GCC also accept a double-const declation:

  //identical to ??: const int *       ptrToConst2;
  //superfluous const? No warning nor error.
  const int const * ptrToConst3;

The superfluous 'const' declaration does not generate error or warning.
It's obvious that the programmer most likely wanted to declare
"constant pointer to constant data", but he only gets
"pointer to constant data". He should get a warning or parse error for this.
It's no meaning to declare 'constant data' twice.
The second const-declaration does not have any effect.

I'm compiling with GCC-4.5.1 and having all possible warning flags:
"-W -Wall -Wextra".

I also attach small example file with test of various const-declarations.


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

* [Bug c/46765] Superfluous 'const' declaration does not generate error or warning
  2010-12-02 13:34 [Bug c/46765] New: Superfluous 'const' declaration does not generate error or warning fredrik.hederstierna@securitas-direct.com
@ 2010-12-02 13:34 ` fredrik.hederstierna@securitas-direct.com
  2010-12-02 16:57 ` jsm28 at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: fredrik.hederstierna@securitas-direct.com @ 2010-12-02 13:34 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Fredrik Hederstierna <fredrik.hederstierna@securitas-direct.com> 2010-12-02 13:34:26 UTC ---
Created attachment 22602
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=22602
example file for const.


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

* [Bug c/46765] Superfluous 'const' declaration does not generate error or warning
  2010-12-02 13:34 [Bug c/46765] New: Superfluous 'const' declaration does not generate error or warning fredrik.hederstierna@securitas-direct.com
  2010-12-02 13:34 ` [Bug c/46765] " fredrik.hederstierna@securitas-direct.com
@ 2010-12-02 16:57 ` jsm28 at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: jsm28 at gcc dot gnu.org @ 2010-12-02 16:57 UTC (permalink / raw)
  To: gcc-bugs

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

Joseph S. Myers <jsm28 at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |DUPLICATE

--- Comment #2 from Joseph S. Myers <jsm28 at gcc dot gnu.org> 2010-12-02 16:57:02 UTC ---
See bug 43651.

*** This bug has been marked as a duplicate of bug 43651 ***


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

end of thread, other threads:[~2010-12-02 16:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-02 13:34 [Bug c/46765] New: Superfluous 'const' declaration does not generate error or warning fredrik.hederstierna@securitas-direct.com
2010-12-02 13:34 ` [Bug c/46765] " fredrik.hederstierna@securitas-direct.com
2010-12-02 16:57 ` jsm28 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).