This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/15771] New: std::assert(true) doesn't compile, assert(true) does (but shouldn't).


The following is valid c++:
#include <cassert>
int main()
{
    std::assert(true);
}
but fails with the following message
> g++ t.cc
t.cc: In function `int main()':
t.cc:5: error: parse error before `static_cast'
>
Removing the namespace qualification 'std::' makes the example compile, *which
it shouldn't*! Without an explicit 'using' declaration, g++ ought to say
'`assert' undeclared (first use in this function'.

Further diagnostics:
> g++ -v -save-temps t.cc
Reading specs from /usr/lib/gcc-lib/i586-suse-linux/3.3.1/specs
Configured with: ../configure --enable-threads=posix --prefix=/usr
--with-local-prefix=/usr/local --infodir=/usr/share/info --mandir=/usr/share/man
--libdir=/usr/lib --enable-languages=c,c++,f77,objc,java,ada --disable-checking
--enable-libgcj --with-gxx-include-dir=/usr/include/g++ --with-slibdir=/lib
--with-system-zlib --enable-shared --enable-__cxa_atexit i586-suse-linux
Thread model: posix
gcc version 3.3.1 (SuSE Linux)
 /usr/lib/gcc-lib/i586-suse-linux/3.3.1/cc1plus -E -D__GNUG__=3 -quiet -v
-D__GNUC__=3 -D__GNUC_MINOR__=3 -D__GNUC_PATCHLEVEL__=1 -D_GNU_SOURCE t.cc t.ii
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/g++
 /usr/include/g++/i586-suse-linux
 /usr/include/g++/backward
 /usr/local/include
 /usr/lib/gcc-lib/i586-suse-linux/3.3.1/include
 /usr/i586-suse-linux/include
 /usr/include
End of search list.
 /usr/lib/gcc-lib/i586-suse-linux/3.3.1/cc1plus -fpreprocessed t.ii -quiet
-dumpbase t.cc -auxbase t -version -o t.s
GNU C++ version 3.3.1 (SuSE Linux) (i586-suse-linux)
        compiled by GNU C version 3.3.1 (SuSE Linux).
GGC heuristics: --param ggc-min-expand=64 --param ggc-min-heapsize=64290
t.cc: In function `int main()':
t.cc:5: error: parse error before `static_cast'
>

t.ii:
# 1 "t.cc"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "t.cc"
# 1 "/usr/include/g++/cassert" 1 3
# 47 "/usr/include/g++/cassert" 3

# 1 "/usr/include/assert.h" 1 3 4
# 36 "/usr/include/assert.h" 3 4
# 1 "/usr/include/features.h" 1 3 4
# 295 "/usr/include/features.h" 3 4
# 1 "/usr/include/sys/cdefs.h" 1 3 4
# 296 "/usr/include/features.h" 2 3 4
# 318 "/usr/include/features.h" 3 4
# 1 "/usr/include/gnu/stubs.h" 1 3 4
# 319 "/usr/include/features.h" 2 3 4
# 37 "/usr/include/assert.h" 2 3 4
# 65 "/usr/include/assert.h" 3 4
extern "C" {


extern void __assert_fail (__const char *__assertion, __const char *__file,
                           unsigned int __line, __const char *__function)
     throw () __attribute__ ((__noreturn__));


extern void __assert_perror_fail (int __errnum, __const char *__file,
                                  unsigned int __line,
                                  __const char *__function)
     throw () __attribute__ ((__noreturn__));




extern void __assert (const char *__assertion, const char *__file, int __line)
     throw () __attribute__ ((__noreturn__));


}
# 49 "/usr/include/g++/cassert" 2 3
# 2 "t.cc" 2

int main()
{
    std::(static_cast<void> (__builtin_expect (!!(true), 1) ? 0 : (__assert_fail
("true", "t.cc", 5, __PRETTY_FUNCTION__), 0)));
}

-- 
           Summary: std::assert(true) doesn't compile, assert(true) does
                    (but shouldn't).
           Product: gcc
           Version: 3.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: thorstein at thorsteinsson dot net
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15771


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]