When #pragma GCC visibility push(default) #pragma GCC visibility pop are used for header file wrappers, we may have more 16 #pragma GCC visibility push(default) Currently gcc will fail.
This is a documented behavior.
It makes it less useful for header file wrappers. Supporting the case of N (N>16) #pragma GCC visibility push(default) followed by N #pragma GCC visibility pop shouldn't be very hard.
A patch is posted at http://gcc.gnu.org/ml/gcc-patches/2005-03/msg00238.html
Subject: Re: Can't push more than 16 nested visibility On Thu, 3 Mar 2005, pinskia at gcc dot gnu dot org wrote: > This is a documented behavior. Arbitrary limits are still generally undesirable, even when documented. Some limits are very unlikely to be reached by real programs, even computer-generated ones, and genuinely motivated by efficiency. For example, the C front end only supports 268435455 (= 2^28 - 1) nested scopes. If there were a real use for more scopes, or for a very few programs to exceed other such limits motivated by efficiency concerns, we could add a --enable-huge-programs configure option to increase those limits at some performance cost to almost all normal programs. Another limit in a similar situation is the limit of USHRT_MAX parameters to a preprocessor macro. In this case, the limit is reached by real code and I very much doubt (without profiling information to show to the contrary) that there would be any measurable performance difference with using VEC, so we should just do that and get rid of the limit.
(In reply to comment #4) I strongly agree with everything in JSM's post. There is simply no reason for keeping such a stupid limit, and even less for manually optimizing conditions to enhance the limit. Using a VEC is more than enough for this case.
A new patch is posted at http://gcc.gnu.org/ml/gcc-patches/2005-04/msg00567.html
Subject: Bug 20303 CVSROOT: /cvs/gcc Module name: gcc Changes by: hjl@gcc.gnu.org 2005-05-30 18:49:04 Modified files: gcc : ChangeLog c-pragma.c gcc/doc : invoke.texi Log message: 2005-05-30 H.J. Lu <hongjiu.lu@intel.com> PR middle-end/20303 * c-pragma.c: Include "vec.h". (handle_pragma_visibility): Use VEC. * doc/invoke.texi: Remove the nested visibility push limit. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.8947&r2=2.8948 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-pragma.c.diff?cvsroot=gcc&r1=1.85&r2=1.86 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/doc/invoke.texi.diff?cvsroot=gcc&r1=1.626&r2=1.627
Fixed on mainline.
Any reason why this hasn't been fixed on gcc-4_0-branch as well?
A patch for gcc 4.0 is posted at http://gcc.gnu.org/ml/gcc-patches/2005-07/msg00994.html
Subject: Bug 20303 CVSROOT: /cvs/gcc Module name: gcc Changes by: jakub@gcc.gnu.org 2005-07-25 07:38:58 Modified files: gcc/testsuite : ChangeLog Added files: gcc/testsuite/gcc.dg: visibility-d.c Log message: PR middle-end/20303 * gcc.dg/visibility-d.c: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5812&r2=1.5813 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/visibility-d.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
Subject: Bug 20303 Author: jakub Date: Mon Nov 21 09:43:10 2005 New Revision: 107290 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=107290 Log: 2005-05-18 H.J. Lu <hongjiu.lu@intel.com> PR middle-end/20303 * c-pragma.c: Include "vec.h". (handle_pragma_visibility): Use VEC. * doc/invoke.texi: Remove the nested visibility push limit. 2005-07-22 Jakub Jelinek <jakub@redhat.com> PR middle-end/20303 * gcc.dg/visibility-d.c: New test. Added: branches/gcc-4_0-rhl-branch/gcc/testsuite/gcc.dg/visibility-d.c Modified: branches/gcc-4_0-rhl-branch/gcc/ChangeLog branches/gcc-4_0-rhl-branch/gcc/c-pragma.c branches/gcc-4_0-rhl-branch/gcc/doc/invoke.texi branches/gcc-4_0-rhl-branch/gcc/testsuite/ChangeLog
Fixed in 4.1.0, this was not a regression.