Is -Werror=pedantic necessary?

Daniel van Vugt daniel.van.vugt at canonical.com
Fri Nov 15 01:39:20 UTC 2013


I would prefer to keep pedantic mode. Issues like using C99 
designated-initializers in C++ are actually compliance issues you should 
be told about. It's nice to know when you're no longer using the 
language standard you told the compiler you would use.

If you need to include other peoples' code which use non-compliant 
language features then why not just:

    #pragma GCC diagnostic push
    #pragma GCC diagnostic ignored "-pedantic"
    #include <noncompliant.h>
    #pragma GCC diagnostic pop

or localize the removal of pedantic (like we already do):

    string(REPLACE "-pedantic" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})



On 15/11/13 07:14, Christopher James Halse Rogers wrote:
> Hey all,
>
> Just a quick one, but one that might generate lots of discussion: should
> we be building with -Werror=pedantic? What does this buy us?
>
> It *costs* us things like C99 designated-initialisers, which are nice.
>
> As far as I can tell from the gcc manpage, -pedantic doesn't produce
> errors for code where it's likely that the behaviour intended by the
> programmer doesn't match the actual behaviour (ie: it doesn't seem like
> it will help catch coding errors). -pedantic *explicitly* doesn't
> provide a guarantee that code that builds with -pedantic set will build
> on another ISO C++-compliant compiler, and we already get most of that
> benefit by building with clang anyway.
>
> This message brought to you by my latest build failing again because of
> the use of C99 designated-initialisers where they're obviously
> appropriate.
>
> (If it turns out that we do get value from -Werror=pedantic; great! I
> can refer back to the message next time I get annoyed at not being able
> to use sensible features ☺).
>
> Chris
>
>
>



More information about the Mir-devel mailing list