[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#595380: mqueue2.h: declaration of ‘mqd_t mq_open(const char*, int, ...)’ throws different exceptions



Package: libc6-dev
Version: 2.11.2-2
Severity: normal
Tags: upstream


Hi, I think this is an upstream bug, but in the glibc page says I should
report the bug to the distribution first, so here it is. See this small
test case:

$ cat test.cpp
#include <mqueue.h>
int main()
{
	mq_open("/tmp/test", O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR, 0);
	return 0;
}
$ g++ -D_FORTIFY_SOURCE=1 -c test.cpp # OK
$ g++ -O -D_FORTIFY_SOURCE=1 -c test.cpp # OK
$ g++ -pedantic -D_FORTIFY_SOURCE=1 -c test.cpp # OK
$ g++ -O -pedantic -D_FORTIFY_SOURCE=1 -c test.cpp # FAIL
In file included from /usr/include/mqueue.h:97,
                 from test.cpp:2:
/usr/include/bits/mqueue2.h: In function ‘mqd_t mq_open(const char*, int, ...)’:
/usr/include/bits/mqueue2.h:37: error: declaration of ‘mqd_t mq_open(const char*, int, ...)’ throws different exceptions
/usr/include/bits/mqueue2.h:26: error: from previous declaration ‘mqd_t mq_open(const char*, int, ...) throw ()’
$ g++ -O -pedantic -D_FORTIFY_SOURCE=0 -c test.cpp # OK


The problem seems to be that -O defines the macro __OPTIMIZE__=1 and I'm
using GCC >= 4.1 (Debian 4.4.4-8), then the macro __USE_FORTIFY_LEVEL is
defined to 1 in features.h (around line 301:

#if defined _FORTIFY_SOURCE && _FORTIFY_SOURCE > 0 \
    && __GNUC_PREREQ (4, 1) && defined __OPTIMIZE__ && __OPTIMIZE__ > 0
# if _FORTIFY_SOURCE > 1
#  define __USE_FORTIFY_LEVEL 2
# else
#  define __USE_FORTIFY_LEVEL 1
# endif
#else
# define __USE_FORTIFY_LEVEL 0
#endif


Finally, mqueue.h (around line 95):
/* Define some inlines helping to catch common problems.  */

#if __USE_FORTIFY_LEVEL > 0 && defined __extern_always_inline \
    && defined __va_arg_pack_len
# include <bits/mqueue2.h>
#endif


This includes bits/mqueue2.h which seems to be broken in C++, look how it's
expanded:

$ g++ -O -pedantic -D_FORTIFY_SOURCE=1 -o- -E -xc++ test.cpp | tail -n43 | cat -n
     1  # 1 "/usr/include/bits/mqueue2.h" 1 3 4
     2  # 26 "/usr/include/bits/mqueue2.h" 3 4
     3  extern mqd_t mq_open (__const char *__name, int __oflag, ...)
     4       throw () __attribute__ ((__nonnull__ (1)));
     5  extern mqd_t __mq_open_2 (__const char *__name, int __oflag) __attribute__ ((__nonnull__ (1)));
     6  extern mqd_t __mq_open_alias (__const char *__name, int __oflag, ...) __asm__ ("" "mq_open") __attribute__ ((__nonnull__ (1)));
     7  
     8  extern void __mq_open_wrong_number_of_args (void) __attribute__((__error__ ("mq_open can be called either with 2 or 4 arguments")));
     9  
    10  extern void __mq_open_missing_mode_and_attr (void) __attribute__((__error__ ("mq_open with O_CREAT in second argument needs 4 arguments")));
    11  
    12  
    13  extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__, __artificial__)) mqd_t
    14  mq_open (__const char *__name, int __oflag, ...)
    15  {
    16    if (__builtin_va_arg_pack_len () != 0 && __builtin_va_arg_pack_len () != 2)
    17      __mq_open_wrong_number_of_args ();
    18  
    19    if (__builtin_constant_p (__oflag))
    20      {
    21        if ((__oflag & 0100) != 0 && __builtin_va_arg_pack_len () == 0)
    22   {
    23     __mq_open_missing_mode_and_attr ();
    24     return __mq_open_2 (__name, __oflag);
    25   }
    26        return __mq_open_alias (__name, __oflag, __builtin_va_arg_pack ());
    27      }
    28  
    29    if (__builtin_va_arg_pack_len () == 0)
    30      return __mq_open_2 (__name, __oflag);
    31  
    32    return __mq_open_alias (__name, __oflag, __builtin_va_arg_pack ());
    33  }
    34  # 97 "/usr/include/mqueue.h" 2 3 4
    35  
    36  
    37  }
    38  # 2 "test.cpp" 2
    39  int main()
    40  {
    41   mq_open("/tmp/test", 0100 | 01, 0400 | 0200, 0);
    42          return 0;
    43  }


In line 3 mq_open() is declared with throw(), but in the definition in
line 13/14 throw() is not specified.


-- System Information:
Debian Release: squeeze/sid
  APT prefers testing
  APT policy: (990, 'testing'), (100, 'unstable'), (50, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.35.2 (SMP w/4 CPU cores)
Locale: LANG=es_AR.UTF-8, LC_CTYPE=es_AR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages libc6-dev depends on:
ii  libc-dev-bin                  2.11.2-2   Embedded GNU C Library: Developmen
ii  libc6                         2.11.2-2   Embedded GNU C Library: Shared lib
ii  linux-libc-dev                2.6.32-20  Linux support headers for userspac

Versions of packages libc6-dev recommends:
ii  gcc [c-compiler]              4:4.4.4-2  The GNU C compiler
ii  gcc-4.1 [c-compiler]          4.1.2-29   The GNU C compiler
ii  gcc-4.3 [c-compiler]          4.3.5-2    The GNU C compiler
ii  gcc-4.4 [c-compiler]          4.4.4-8    The GNU C compiler
ii  gcc-4.5 [c-compiler]          4.5.1-3    The GNU C compiler

Versions of packages libc6-dev suggests:
pn  glibc-doc                     <none>     (no description available)
ii  manpages-dev                  3.25-1     Manual pages about using GNU/Linux

-- no debconf information



Reply to: