[gcc 5.0] error: '{anonymous}::gtest_pkixder_DigestAlgorithmIdentifier_Validpkixder_DigestAlgorithmIdentifier_Valid_dummy_' defined but not used [-Werror=unused-variable]

RESOLVED FIXED in Firefox 40

Status

defect
RESOLVED FIXED
4 years ago
4 years ago

People

(Reporter: glandium, Assigned: glandium)

Tracking

(Blocks 1 bug)

unspecified
mozilla40
All
Linux
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(firefox40 fixed)

Details

Attachments

(1 attachment, 1 obsolete attachment)

(There doesn't seem to be a component for gtest)

When building with gcc 5.0 and --enable-warnings-as-errors:

23:49:36     INFO -  /builds/slave/try-lx-00000000000000000000000/build/src/security/pkix/test/gtest/pkixder_pki_types_tests.cpp: At global scope:
23:49:36     INFO -  /builds/slave/try-lx-00000000000000000000000/build/src/security/pkix/test/gtest/pkixder_pki_types_tests.cpp:268:259: error: '{anonymous}::gtest_pkixder_DigestAlgorithmIdentifier_Validpkixder_DigestAlgorithmIdentifier_Valid_dummy_' defined but not used [-Werror=unused-variable]
23:49:36     INFO -  /builds/slave/try-lx-00000000000000000000000/build/src/security/pkix/test/gtest/pkixder_pki_types_tests.cpp:304:267: error: '{anonymous}::gtest_pkixder_DigestAlgorithmIdentifier_Invalidpkixder_DigestAlgorithmIdentifier_Invalid_dummy_' defined but not used [-Werror=unused-variable]
23:49:36     INFO -  /builds/slave/try-lx-00000000000000000000000/build/src/security/pkix/test/gtest/pkixder_pki_types_tests.cpp:425:292: error: '{anonymous}::gtest_pkixder_SignatureAlgorithmIdentifierValue_Validpkixder_SignatureAlgorithmIdentifierValue_Valid_dummy_' defined but not used [-Werror=unused-variable]
23:49:36     INFO -  /builds/slave/try-lx-00000000000000000000000/build/src/security/pkix/test/gtest/pkixder_pki_types_tests.cpp:477:285: error: '{anonymous}::gtest_pkixder_SignatureAlgorithmIdentifier_Invalidpkixder_SignatureAlgorithmIdentifier_Invalid_dummy_' defined but not used [-Werror=unused-variable]
23:49:36     INFO -  /builds/slave/try-lx-00000000000000000000000/build/src/security/pkix/test/gtest/pkixder_pki_types_tests.cpp:237:940: error: '{anonymous}::pkixder_DigestAlgorithmIdentifier_Valid_Valid_Test::gtest_registering_dummy_' defined but not used [-Werror=unused-variable]
23:49:36     INFO -  /builds/slave/try-lx-00000000000000000000000/build/src/security/pkix/test/gtest/pkixder_pki_types_tests.cpp:293:974: error: '{anonymous}::pkixder_DigestAlgorithmIdentifier_Invalid_Invalid_Test::gtest_registering_dummy_' defined but not used [-Werror=unused-variable]
23:49:36     INFO -  /builds/slave/try-lx-00000000000000000000000/build/src/security/pkix/test/gtest/pkixder_pki_types_tests.cpp:387:1020: error: '{anonymous}::pkixder_SignatureAlgorithmIdentifierValue_Valid_Valid_Test::gtest_registering_dummy_' defined but not used [-Werror=unused-variable]
23:49:36     INFO -  /builds/slave/try-lx-00000000000000000000000/build/src/security/pkix/test/gtest/pkixder_pki_types_tests.cpp:465:1004: error: '{anonymous}::pkixder_SignatureAlgorithmIdentifier_Invalid_Invalid_Test::gtest_registering_dummy_' defined but not used [-Werror=unused-variable]
23:49:36     INFO -  cc1plus: all warnings being treated as errors
I don't have gcc 5.0, but I believe the problem is security/pkix/test/gtest/pkixder_pki_types_tests.cpp calls INSTANTIATE_TEST_CASE_P macro [1] inside an unnamed namespace. INSTANTIATE_TEST_CASE_P's gtest dummy variables like {anonymous}::gtest_pkixder_DigestAlgorithmIdentifier_Validpkixder_DigestAlgorithmIdentifier_Valid_dummy_ are effectively static and gcc can see that they are unused within the unnamed namespace. I assume pkixder_pki_types_tests.cpp encapsulates all its tests in one big unnamed namespace to avoid name conflicts from unified files.

https://mxr.mozilla.org/mozilla-central/source/testing/gtest/gtest/include/gtest/gtest-param-test.h#1409
Blocks: buildwarning
Try build of WIP patch to see if removing the unnamed namespace breaks unified builds of pkix:

https://treeherder.mozilla.org/#/jobs?repo=try&revision=af84f475ffeb
You can do a try build with an almost-5.0 GCC with this:
https://hg.mozilla.org/try/rev/1c8a82e5d979

(you don't need the build-gcc.sh change ; the mozconfig.common.override change is because of bug 1153109)
FWIW, I pushed your patch to try to see if there are more warning-as-errors after this one (if it works)
It seems to work, but there are other files with the same problem. My try push with this fix now hit the same kind of error on pkixder_universal_types_tests.cpp.
Did you try building upstream gtest to see if this is fixed there?
(In reply to Ted Mielczarek [:ted.mielczarek] from comment #6)
> Did you try building upstream gtest to see if this is fixed there?

It seems to be specific to us, cf. the patch that works.
This avoids -Wunused-variable fatal warnings with GCC 5.0.
Assignee: nobody → mh+mozilla
Attachment #8590673 - Attachment is obsolete: true
Attachment #8592104 - Flags: review?(dkeeler)
Comment on attachment 8592104 [details] [diff] [review]
Remove anonymous namespace around pkix gtests

Review of attachment 8592104 [details] [diff] [review]:
-----------------------------------------------------------------

I imagine this is fine, but I'd like Brian to weigh in if he has any concerns or a different approach that will address the issue.
(In particular, there are some other anonymous namespaces in mozpkix gtests, but for some reason they appear not to have the same problem.)
Attachment #8592104 - Flags: review?(dkeeler) → review?(brian)
Comment on attachment 8592104 [details] [diff] [review]
Remove anonymous namespace around pkix gtests

Review of attachment 8592104 [details] [diff] [review]:
-----------------------------------------------------------------

Thanks for writing this.

FWIW, we don't use unified builds in security/pkix because it's important that the code always builds correctly in non-unified builds, in particular when it is used outside of Gecko (e.g. in some future version of NSS).
Attachment #8592104 - Flags: review?(brian) → review+
https://hg.mozilla.org/mozilla-central/rev/4797f13df904
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla40
You need to log in before you can comment on or make changes to this bug.