Opened 13 years ago

Closed 12 years ago

#3520 closed Bugs (fixed)

Syntax Error in boost/typeof/typeof.hpp

Reported by: Jason Masters <jason_masters@…> Owned by: Peder Holt
Milestone: Boost 1.45.0 Component: typeof
Version: Boost 1.40.0 Severity: Problem
Keywords: syntax error typeof.hpp Cc:

Description

Line 18 of boost/typeof/typeof.hpp is:

# ifndef(BOOST_TYPEOF_EMULATION)

I don't think the brackets around the macro are correct. This line is within an ifdef for the COMO macro: the header file has similar blocks for other compilers, which do not have the brackets on the similar ifndef lines.

Note that unless you use the COMO compiler your (other) compiler (e.g. g++) might not warn about this syntax error, but code within conditionally included code must still be syntactically correct, even though it is not actually included in the Translation Unit. This issue was found with PRQA QAC++, which does report recoverable issues in non-included code.

Change History (4)

comment:1 by Steven Watanabe, 13 years ago

The Boost.Typeof tests pass with como...

comment:2 by Jason Masters <jason_masters@…>, 13 years ago

Do the Boost.Typeof tests define both __COMO__ and __GNUG__ ? I have checked a testcase of the issue with the online Comeau test:

#if defined(__COMO__)
#   ifdef __GNUG__
#       ifndef(BOOST_TYPEOF_EMULATION)
#           define BOOST_TYPEOF_KEYWORD typeof
#       endif
#   endif
#endif

With no defines this compiles successfully. With command line options -D__COMO__ -D__GNUG__ we get:

"ComeauTest.c", line 3: error: expected an identifier
  #       ifndef(BOOST_TYPEOF_EMULATION)
                ^
1 error detected in the compilation of "ComeauTest.c".

Which is what I would expect. If just __COMO__ is defined then compilation is successful. Even if the como compiler does parse this code successfully it is still wrong - other compilers still have to parse the code in the non-included #ifdef sections.

comment:3 by Steven Watanabe, 13 years ago

I see. I ran the tests with msvc as the backend.

comment:4 by Peder Holt, 12 years ago

Milestone: Boost 1.41.0Boost-1.45.0
Resolution: fixed
Status: newclosed

This is now be fixed

Note: See TracTickets for help on using tickets.