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

googletest uses std::tr1 which will be deprecated in VS 2017 #1111

Closed
StephanTLavavej opened this issue Jun 7, 2017 · 22 comments
Closed

googletest uses std::tr1 which will be deprecated in VS 2017 #1111

StephanTLavavej opened this issue Jun 7, 2017 · 22 comments

Comments

@StephanTLavavej
Copy link

In VS 2017's second toolset update, I'm going to deprecate the std::tr1 namespace (with the [[deprecated]] attribute, emitting compiler warnings) in both the C++14 and C++17 modes. This will cause googletest's use of std::tr1 to emit warnings (breaking builds under /WX).

While I will provide an escape-hatch macro to silence the deprecation warnings, googletest should migrate away from using std::tr1, as it will be removed in the future (eventually completely, with no escape hatches).

This is almost identical to #872 and #1036 but not quite. Those issues are observing how I removed std::tr1 by default in C++17 mode. This issue is about how std::tr1 will be deprecated even in the default C++14 mode, affecting all users.

@KindDragon
Copy link
Contributor

PR #811 should fix this. But for some reason, no one wants to merge it

@BillyDonahue
Copy link
Contributor

BillyDonahue commented Jun 7, 2017 via email

@mropert
Copy link

mropert commented Jun 21, 2017

Seconding this, today I'm forced to pass -DGTEST_LANG_CXX11=1 to my gtest build to work with VS 2017 in /std mode.

@BillyDonahue
Copy link
Contributor

Stephan, "googletest's use of std::tr1" where? Those uses should be hidden behind platform-version #ifdef directives, please let me know if there's a place this is being done incorrectly.

IIRC, PR #811 is doing more than this, dealing with CMake etc, so it's hard to know it's the right answer for the simpler tr1 migration.

@StephanTLavavej
Copy link
Author

In MSVC's STL, I'm deprecating the namespace by saying namespace std { namespace [[deprecated("MESSAGE")]] tr1 { /* stuff */ } }. As a result, anything that includes an STL header and that mentions std::tr1 will trigger the warning. This will happen even if googletest tries to be clever and says namespace std { namespace tr1 { /* using-declarations or other stuff */ } }, because I have already marked tr1 as deprecated and further openings of the namespace can't un-deprecate it. (Technically, you'll still get away with reopening the namespace like that, but any attempted use of std::tr1::tuple will warn.)

I think

&& !GTEST_OS_QNX && !defined(_LIBCPP_VERSION)) || _MSC_VER >= 1600
is an example of problematic logic - it tries to use std::tr1 even for modern MSVC.

@KindDragon
Copy link
Contributor

KindDragon commented Jun 22, 2017

IIRC, PR #811 is doing more than this, dealing with CMake etc, so it's hard to know it's the right answer for the simpler tr1 migration.

JFYI, PR #811 (#1218) doesn't change cmake files

@BeErikk
Copy link

BeErikk commented Oct 24, 2017

Sorry, as a user I still get this error in the Visual Studio 2017 IDE compile. I have a fresh gtest git clone. Using the compiler outside of the IDE works fine to compile gtest though. Unsure what the default setting is. To get gtest to compile you need to apply -std:c++14

@KindDragon
Copy link
Contributor

Can be closed. PR #1218 fixed this

@andyleejordan
Copy link

Just FYI, if you're a user consuming gtest 1.8.0 and cannot/don't want to patch it, when invoking CMake for it you can use:

-DCMAKE_CXX_FLAGS=/D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING

To keep building. It's a work-around.

@msemegen
Copy link

Still same problem on master build...

@TzuChieh
Copy link

TzuChieh commented Dec 7, 2017

Same here... building from a fresh git clone using VS2017 triggers hundreds of errors about std::tr1.

GreyMerlin added a commit to GreyMerlin/winmerge-v2 that referenced this issue Dec 7, 2017
 * Using the latest (and just released) version 15.5.0 of VS2017
introduces the following error into the UnitTests project ...

"error C4996: 'std::tr1': warning STL4002: The non-Standard std::tr1
namespace and TR1-only machinery are deprecated and will be REMOVED.
You can define _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING to
acknowledge that you have received this warning. "

* MSDN claims that this is a C++17 language standards issue, but I was
not able to solve this problem by specifying the use of the C++14
standard language (the Properties control for this is likewise a new
feature of version 15.5.0) See...
https://docs.microsoft.com/en-us/cpp/cpp-conformance-improvements-2017

* The only simple, short-term solution that I could come up with was to
simply follow the suggestion of defining the _SILENCE_TR1_xxx token as
given above.

* Even though this problem has been discussed in the GoogleTest github
forum since at least 6 June, the underlying problem remains un-resolved
at this hour ...
	See google/googletest#1111
	See google/googletest#1320
	See google/googletest#1311

* I will assume that Google's resolution of this problem will require
WinMerge to adopt the newest GoogleTest framework (which is likely a
good idea anyway).  I will keep an eye on their progress and resolution
and advise accordingly.  In the meantime, this kludge allows WinMerge's
UnitTests project to compile and execute correctly.
@Ozaq
Copy link

Ozaq commented Dec 14, 2017

Will this trigger a new release? I now have the problem that our organization requires 'official' releases for third party software but we also keep all software (including Visual studio) up to date

tgregg pushed a commit to amazon-ion/ion-c that referenced this issue Jan 5, 2018
Visual Studio 17, tools update 2 (15.5) makes the use of std::tr1
deprecated and an error at /W3.  This ignores that error and should
be removed once googletest fixes this upstream.

see: google/googletest#1111
blowekamp added a commit to blowekamp/SimpleITK that referenced this issue Jan 9, 2018
The 1.8.0 release has issues with MSVC 2017. The usage of tr1 produces
a warning, and flags are enable so that warnings are enabled. The
selected version of GoogleTest is the same one that ITK is using has a
fix for the issue.

google/googletest#1111
augustoproiete pushed a commit to sandboxorg/winmerge that referenced this issue Feb 6, 2018
 * Using the latest (and just released) version 15.5.0 of VS2017
introduces the following error into the UnitTests project ...

"error C4996: 'std::tr1': warning STL4002: The non-Standard std::tr1
namespace and TR1-only machinery are deprecated and will be REMOVED.
You can define _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING to
acknowledge that you have received this warning. "

* MSDN claims that this is a C++17 language standards issue, but I was
not able to solve this problem by specifying the use of the C++14
standard language (the Properties control for this is likewise a new
feature of version 15.5.0) See...
https://docs.microsoft.com/en-us/cpp/cpp-conformance-improvements-2017

* The only simple, short-term solution that I could come up with was to
simply follow the suggestion of defining the _SILENCE_TR1_xxx token as
given above.

* Even though this problem has been discussed in the GoogleTest github
forum since at least 6 June, the underlying problem remains un-resolved
at this hour ...
	See google/googletest#1111
	See google/googletest#1320
	See google/googletest#1311

* I will assume that Google's resolution of this problem will require
WinMerge to adopt the newest GoogleTest framework (which is likely a
good idea anyway).  I will keep an eye on their progress and resolution
and advise accordingly.  In the meantime, this kludge allows WinMerge's
UnitTests project to compile and execute correctly.
khizmax added a commit to khizmax/libcds that referenced this issue Mar 24, 2018
hubot pushed a commit to webmproject/libvpx that referenced this issue Mar 27, 2018
Address std::tr1::tuple warnings:
google/googletest#1111

The unsigned overflow fix has been superseded by:
google/googletest#1180

Change-Id: I92dc0ba08a4d0d63f5e5b2da7b64f4a4642ed9ab
biojppm added a commit to biojppm/c4core that referenced this issue Mar 30, 2018
jlblancoc added a commit to MRPT/mrpt that referenced this issue Apr 1, 2018
hobu pushed a commit to PDAL/PDAL that referenced this issue Aug 14, 2018
gtest uses std::tr1 which has been deprecated in VS 2017
google/googletest#1111
Without _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING define, MSVC
generates warnings and, since warnings are treated as errors,
compilation fails.
kaspermarstal pushed a commit to SuperElastix/SimpleElastix that referenced this issue Sep 10, 2018
The 1.8.0 release has issues with MSVC 2017. The usage of tr1 produces
a warning, and flags are enable so that warnings are enabled. The
selected version of GoogleTest is the same one that ITK is using has a
fix for the issue.

google/googletest#1111
@gennadiycivil
Copy link
Contributor

TR1 tuple and our own implementation of tuple has been removed from master

sdottaka pushed a commit to sdottaka/winmerge-v2-jp that referenced this issue Nov 4, 2018
 * Using the latest (and just released) version 15.5.0 of VS2017
introduces the following error into the UnitTests project ...

"error C4996: 'std::tr1': warning STL4002: The non-Standard std::tr1
namespace and TR1-only machinery are deprecated and will be REMOVED.
You can define _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING to
acknowledge that you have received this warning. "

* MSDN claims that this is a C++17 language standards issue, but I was
not able to solve this problem by specifying the use of the C++14
standard language (the Properties control for this is likewise a new
feature of version 15.5.0) See...
https://docs.microsoft.com/en-us/cpp/cpp-conformance-improvements-2017

* The only simple, short-term solution that I could come up with was to
simply follow the suggestion of defining the _SILENCE_TR1_xxx token as
given above.

* Even though this problem has been discussed in the GoogleTest github
forum since at least 6 June, the underlying problem remains un-resolved
at this hour ...
	See google/googletest#1111
	See google/googletest#1320
	See google/googletest#1311

* I will assume that Google's resolution of this problem will require
WinMerge to adopt the newest GoogleTest framework (which is likely a
good idea anyway).  I will keep an eye on their progress and resolution
and advise accordingly.  In the meantime, this kludge allows WinMerge's
UnitTests project to compile and execute correctly.
@rleigh-codelibre
Copy link

@gennadiycivil Is there any ETA on a release containing this fix?

@gennadiycivil
Copy link
Contributor

gennadiycivil commented Nov 12, 2018 via email

@rleigh-codelibre
Copy link

@gennadiycivil I meant that now the tr1 stuff is dropped from master, is there an ETA for a public release containing these fixes? It's a bit of a blocker for C++17 development. While I'm currently working with custom builds off master, having this in e.g. vcpkg and other common distributions would be highly desirable.

@gennadiycivil
Copy link
Contributor

gennadiycivil commented Nov 13, 2018 via email

@thomthom
Copy link

thomthom commented Dec 2, 2018

It appear that using 1.8.1 there is no longer any need for _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING.
(Just an FYI. To me this wasn't clear based on the notes in the GitHub release or from this issue.)

@denysvitali
Copy link

Or, if you're using googletest 1.8.3 from NuGet, remember to read the package details: you need to add GTEST_LANG_CXX11 to the compiler definitions, so that your code can be compiled w/ VC++17.
I just lost an hour trying to understand why it didn't compile. 🤷‍♂️

@damian123
Copy link

This issue still remains. Can we roll the fix out please?
Since many projects depends on gtest it is very annoying for these to maintain workarounds.
Thanks!

@gennadiycivil
Copy link
Contributor

@damian123 not clear what 'issue' you are referring to and what exactly ' roll the fix' mean - could you please explain.

@gennadiycivil
Copy link
Contributor

@gennadiycivil I meant that now the tr1 stuff is dropped from master, is there an ETA for a public release containing these fixes? It's a bit of a blocker for C++17 development. While I'm currently working with custom builds off master, having this in e.g. vcpkg and other common distributions would be highly desirable.

There is a number of assumtions in this question that I think should be addressed:

  1. "Public release" : I am not aware of the terminology. Yes at some point we will cut a branch of the code and will call it 1.9.x . This is it, that is the extent of the "release". As to "public" I would like to help but simiply not aware what this means, everything in this GitHub repo is already public.

You may just as well pick a point in the master and use it.

  1. " having this in e.g. vcpkg and other common distributions would be highly desirable." - if this is your development process, of course, this would make sense. However this is not in googletest hands. While we welcome "someone else" to pakage googletest if they so desire, we don't' explicitly do it ourselves.

Hope this helps.

In additon, this is a reply to "closed" GitHub issue, and there is a very high chance I will never see it because of the filters. It may be better to open a new issue if we need to communicate more.

Thanks
G

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests