Beginning on October 25th, 2016, Persona will no longer be an option for authentication on BMO. For more details see Persona Deprecated.
Last Comment Bug 702090 - compilation error: pkcs11n.h:365:26: error: "__GNUC_MINOR" is not defined
: compilation error: pkcs11n.h:365:26: error: "__GNUC_MINOR" is not defined
Product: NSS
Classification: Components
Component: Libraries (show other bugs)
: 3.13.1
: All Linux
: P2 normal (vote)
: 3.13.2
Assigned To: Elio Maldonado
Depends on:
  Show dependency treegraph
Reported: 2011-11-13 00:32 PST by Stefan Becker
Modified: 2012-02-14 22:34 PST (History)
6 users (show)
See Also:
Crash Signature:
QA Whiteboard:
Iteration: ---
Points: ---

fix (966 bytes, patch)
2011-11-18 07:47 PST, Takanori MATSUURA
kaie: review+
Details | Diff | Splinter Review

Description Stefan Becker 2011-11-13 00:32:25 PST

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.


In 3.13.1 pkcs11n.h has this construct:

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

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


pkcs11n.h should have instead:

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

That should work with all compilers and fix the __GNUC_MINOR__ typo.
Comment 1 Stefan Becker 2011-11-13 04:11:13 PST
The problem was introduced in v1.22 with the fix for bug #642503.

See comment:
Comment 2 Robert Relyea 2011-11-14 14:17:53 PST
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.

Comment 3 Takanori MATSUURA 2011-11-18 07:47:36 PST
Created attachment 575453 [details] [diff] [review]

Prepare a patch what comment 0 says.
Comment 4 Kai Engert (:kaie) 2011-11-24 04:23:21 PST
Comment on attachment 575453 [details] [diff] [review]

This is obviously correct. r=kaie
Comment 5 Kai Engert (:kaie) 2011-11-24 04:26:50 PST
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
Comment 6 Wan-Teh Chang 2012-02-14 19:17:37 PST
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.
Comment 7 Stefan Becker 2012-02-14 22:34:24 PST
(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.

Note You need to log in before you can comment on or make changes to this bug.