public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/64644] New: "warning: anonymous union with no members" should be an error with -pedantic-errors
@ 2015-01-17 12:34 harald at gigawatt dot nl
  2015-01-18 22:54 ` [Bug c++/64644] " harald at gigawatt dot nl
  2015-01-19  0:50 ` manu at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: harald at gigawatt dot nl @ 2015-01-17 12:34 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 64644
           Summary: "warning: anonymous union with no members" should be
                    an error with -pedantic-errors
           Product: gcc
           Version: 4.9.2
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: harald at gigawatt dot nl

Compiling

    static union { };

with gcc -std=c++11 -pedantic-errors gives

    test.cc:1:16: warning: anonymous union with no members
     static union { };
                    ^

It's fine that it's a warning by default, but I think it should be an error
with -pedantic-errors, because it violates the last part of [dcl.dcl]p3: when
the init-declarator-list is omitted, "the decl-specifier-seq shall introduce
one or more names into the program, or shall redeclare a name introduced by a
previous declaration." No exception is made for anonymous unions, so the only
way an anonymous union can avoid violating this is by having members.

(FWIW, I cannot find any options to get any warning whatsoever with clang,
Intel or Sun, and MSVC only warns at the highest warning level, regardless of
whether language extensions are enabled. As far as I can tell, GCC's current
handling is already the best of these five.)


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

* [Bug c++/64644] "warning: anonymous union with no members" should be an error with -pedantic-errors
  2015-01-17 12:34 [Bug c++/64644] New: "warning: anonymous union with no members" should be an error with -pedantic-errors harald at gigawatt dot nl
@ 2015-01-18 22:54 ` harald at gigawatt dot nl
  2015-01-19  0:50 ` manu at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: harald at gigawatt dot nl @ 2015-01-18 22:54 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Harald van Dijk <harald at gigawatt dot nl> ---
Yep, thanks, testing that on 4.9.2 seems to give the right results. I see it
covered by existing tests in at least
gcc/testsuite/g++.old-deja/g++.law/union4.C and
gcc/testsuite/g++.old-deja/g++.law/union4.C. I'll re-test with GCC 5 soonish
(later in the week, probably), change dg-warning to dg-error where appropriate,
and check if there's already a test to make sure it remains a warning without
-pedantic-errors.

A question, though: I see that like many other existing warnings, this doesn't
handle -Werror=pedantic. Is that something that should be addressed as well, or
is that something that should at some later point be handled for all relevant
warnings at once?


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

* [Bug c++/64644] "warning: anonymous union with no members" should be an error with -pedantic-errors
  2015-01-17 12:34 [Bug c++/64644] New: "warning: anonymous union with no members" should be an error with -pedantic-errors harald at gigawatt dot nl
  2015-01-18 22:54 ` [Bug c++/64644] " harald at gigawatt dot nl
@ 2015-01-19  0:50 ` manu at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: manu at gcc dot gnu.org @ 2015-01-19  0:50 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="UTF-8", Size: 4290 bytes --]

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

--- Comment #3 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
(In reply to Harald van Dijk from comment #2)
> A question, though: I see that like many other existing warnings, this
> doesn't handle -Werror=pedantic. Is that something that should be addressed
> as well, or is that something that should at some later point be handled for
> all relevant warnings at once?

From: https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#Warning-Options

-pedantic-errors
    Give an error whenever the base standard (see -Wpedantic) requires a
diagnostic, in some cases where there is undefined behavior at compile-time and
in some other cases that do not prevent compilation of programs that are valid
according to the standard. This is not equivalent to -Werror=pedantic, since
there are errors enabled by this option and not enabled by the latter and vice
versa.

From: https://gcc.gnu.org/wiki/DiagnosticsGuidelines

pedwarn is for code that is accepted by GCC but it should be rejected or
diagnosed according to the current standard, or it conflicts with the standard
(either the default or the one selected by -std=). Most pedwarns are controlled
by -Wpedantic, a few are controlled by options that are enabled by -Wpedantic
and others are enabled by default. That is, although -Wpedantic is only used
for pedwarns, the choice between using pedwarn or warning is independent of
-Wpedantic and only depends on the current -std= value. 

In my ideal world, -pedantic-errors would be a deprecated (but forever kept for
backwards compatibility) alias of some -Werror=X, where X is either pedantic or
a new -W option. However, the difference between pedwarn(), -Wpedantic and
-pedantic-errors is not very straightforward. You can try to follow the
discussion here: https://gcc.gnu.org/ml/gcc-patches/2014-10/msg01799.html and
if you manage to make some sense out of it and come up with a course of action
(which option to add? what should it enable? what should be its relation with
Wpedantic and -pedantic-errors?) that convinces Joseph Myers, please add it to
PR53075 and I will eventually implement it.
>From gcc-bugs-return-473783-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Mon Jan 19 00:50:53 2015
Return-Path: <gcc-bugs-return-473783-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 7217 invoked by alias); 19 Jan 2015 00:50:51 -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 7164 invoked by uid 48); 19 Jan 2015 00:50:45 -0000
From: "howarth at bromo dot med.uc.edu" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libgomp/64635] darwin produces libgomp-plugin-host_nonshm.1.dylib but tries to load libgomp-plugin-host_nonshm.so.1
Date: Mon, 19 Jan 2015 00:50:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: libgomp
X-Bugzilla-Version: 5.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: howarth at bromo dot med.uc.edu
X-Bugzilla-Status: NEW
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: attachments.created
Message-ID: <bug-64635-4-RA2IZE5DYI@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-64635-4@http.gcc.gnu.org/bugzilla/>
References: <bug-64635-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-01/txt/msg01777.txt.bz2
Content-length: 242

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

--- Comment #13 from howarth at bromo dot med.uc.edu ---
Created attachment 34480
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id4480&actioníit
proposed fix with aix support added


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

end of thread, other threads:[~2015-01-19  0:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-17 12:34 [Bug c++/64644] New: "warning: anonymous union with no members" should be an error with -pedantic-errors harald at gigawatt dot nl
2015-01-18 22:54 ` [Bug c++/64644] " harald at gigawatt dot nl
2015-01-19  0:50 ` manu 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).