Note: There are a few cases of duplicates in user autocompletion which are being worked on.

compilation error: pkcs11n.h:365:26: error: "__GNUC_MINOR" is not defined

RESOLVED FIXED in 3.13.2

Status

NSS
Libraries
P2
normal
RESOLVED FIXED
6 years ago
6 years ago

People

(Reporter: Stefan Becker, Assigned: Elio Maldonado)

Tracking

3.13.1
3.13.2
All
Linux

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

6 years ago
PROBLEM:

A pidgin-sipe user complained about compilation errors when he compiled it against NSS 3.13.1 on OpenSuse 11.4. Here are the important bits from the GCC command line:

gcc ... -Werror -Wall -Wextra -Waggre gate-return -Wcast-align -Wdeclaration-after-statement -Winit-self -Wmissing-dec larations -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wundef ... -I/usr/include/nss3 -I/usr/include/nspr4 ... -c sipe-cert-crypto-nss.c 
cc1: warnings being treated as errors
In file included from /usr/include/nss3/pkcs11t.h:1780:0,
                           from /usr/include/nss3/keythi.h:41,
                           from /usr/include/nss3/keyt.h:41,
                           from /usr/include/nss3/cert.h:55,
                           from sipe-cert-crypto-nss.c:29:
 /usr/include/nss3/pkcs11n.h:365:26: error: "__GNUC_MINOR" is not defined

The same code compiles fine with NSS < 3.13.


ROOT CAUSE:

In 3.13.1 pkcs11n.h has this construct:

#if __GNUC__ > 3
...
#if (__GNUC__ == 4) && (__GNUC_MINOR < 5)
...
#else

which is clearly incorrect. It assumes __GNUC__ is defined, i.e. GCC, and __GNUC_MINOR is a typo.


PROPOSED FIX:

pkcs11n.h should have instead:

#if defined(__GNUC__) && (__GNUC__ > 3)
...
#if (__GNUC__ == 4) && (__GNUC_MINOR__ < 5)
...
#else

That should work with all compilers and fix the __GNUC_MINOR__ typo.
(Reporter)

Comment 1

6 years ago
The problem was introduced in v1.22 with the fix for bug #642503.

See comment: https://bugzilla.mozilla.org/show_bug.cgi?id=642503#c20
Status: UNCONFIRMED → NEW
Ever confirmed: true
Hardware: x86_64 → All

Comment 2

6 years ago
Elio, this looks like the same issue you are dealing with.

The reason we don't trip over the undefines is we don't flip the flag to make undefined comparisons an error.

Also we currently only have built this with GCC 3.x or GCC 4.5 or greater. This patch will allow GCC 4.1, for instance, to work correctly.

bob

Updated

6 years ago
Assignee: nobody → emaldona
Status: NEW → ASSIGNED

Comment 3

6 years ago
Created attachment 575453 [details] [diff] [review]
fix

Prepare a patch what comment 0 says.
Attachment #575453 - Flags: review?(wtc)

Comment 4

6 years ago
Comment on attachment 575453 [details] [diff] [review]
fix

This is obviously correct. r=kaie
Attachment #575453 - Flags: review?(wtc) → review+

Comment 5

6 years ago
checked in

Checking in pkcs11n.h;
/cvsroot/mozilla/security/nss/lib/util/pkcs11n.h,v  <--  pkcs11n.h
new revision: 1.27; previous revision: 1.26
done
Status: ASSIGNED → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → FIXED

Updated

6 years ago

Comment 6

6 years ago
The test
    #if __GNUC__ > 3
is correct even if __GNUC__ is not defined.  The C preprocessor
replaces an undefined macro with 0L in a conditional expression.
So if __GNUC__ is not defined, the test
    #if __GNUC__ > 3
will fail, which is the expected result.
Priority: -- → P2
Target Milestone: --- → 3.13.2
(Reporter)

Comment 7

6 years ago
(In reply to Wan-Teh Chang from comment #6)
> The test
>     #if __GNUC__ > 3
> is correct even if __GNUC__ is not defined.

You are missing the point. Any non-GCC compiler that has the equivalent of GCCs "-Werror -Wundef" will not compile this statement. ARM RVCT would be one example.
You need to log in before you can comment on or make changes to this bug.