Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Old versions of gcc give warnings for pragma diagnostic push and pop #4156

Closed
teeks99 opened this issue Jan 9, 2018 · 2 comments
Closed

Comments

@teeks99
Copy link

teeks99 commented Jan 9, 2018

#pragma GCC diagnostic push and #pragma GCC diagnostic pop are only supported in gcc >= 4.6.

A solution to this would be to change the guards from

#ifdef __GNUC__
  #pragma GCC diagnostic push
  #pragma GCC diagnostic ignored "-Wstrict-aliasing"
#endif  // __GNUC__

and

#ifdef __GNUC__
  #pragma GCC diagnostic pop
#endif  // __GNUC__

To:

#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
  #pragma GCC diagnostic push
  #pragma GCC diagnostic ignored "-Wstrict-aliasing"
#endif  // __GNUC__

and

#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
  #pragma GCC diagnostic pop
#endif  // __GNUC__

There are approximately a dozen header files that do this, as well as the cpp_file.cc codegen. This could be applied to the 3.?.x branches, but might not be needed on master....if master is now c++11, gcc versions before 4.6 might not work with it anyway...I guess it depends on how good various gcc's -std=c++0x support was back then. Might not hurt to apply to master as well.

teeks99 added a commit to teeks99/protobuf that referenced this issue Jan 9, 2018
teeks99 added a commit to teeks99/protobuf that referenced this issue Jan 9, 2018
teeks99 added a commit to teeks99/protobuf that referenced this issue Jan 9, 2018
@xfxyjwf xfxyjwf self-assigned this May 24, 2018
@xfxyjwf xfxyjwf added this to To Do in Weekly Fixit via automation May 24, 2018
@xfxyjwf
Copy link
Contributor

xfxyjwf commented May 24, 2018

@teeks99 We no longer support old gcc versions on the master branch, but we will keep the 3.5.x branch for pre-C++11 support.

jschwartzenberg pushed a commit to jschwartzenberg/upstream_openjfx-8u that referenced this issue Jun 15, 2019
GCC 4.4 does not support -static-libstdc++, so this is replaced with -Bstatic -lstdc++ -Bdynamic which does the same.
Support for pragma diagnostic push and pop also requires a newer GCC, fix based on: protocolbuffers/protobuf#4156
tommie pushed a commit to tommie/tmux that referenced this issue Aug 13, 2019
* In format.c, strftime can do format checking if a string literal is given.
* In options.c, pr "may be used uninitialized", though that can't happen in practice.

The "diagnostic push/pop" pragma was added in GCC 4.6, and according
to protocolbuffers/protobuf#4156, there
would be warnings if we used them for older GCCs.
tommie pushed a commit to tommie/tmux that referenced this issue Aug 13, 2019
* In cmd-new-session.c, dsx and dxy "may be used uninitialized", and it was difficult to tell if that can happen in practice.
* In format.c, strftime can do format checking if a string literal is given.
* In options.c, pr "may be used uninitialized", though that can't happen in practice.

The "diagnostic push/pop" pragma was added in GCC 4.6, and according
to protocolbuffers/protobuf#4156, there
would be warnings if we used them for older GCCs.
@mcy
Copy link
Contributor

mcy commented Sep 1, 2022

GCC versions older than 6.3 are not supported. See https://opensource.google/documentation/policies/cplusplus-support#2_compilers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Weekly Fixit
  
To Do
Development

No branches or pull requests

4 participants