[CppAD-tickets] [C++ Algorithmic Differentiation] #3: "syntax error before `/' token" when using gcc 3.3.5

C++ Algorithmic Differentiation coin-trac at coin-or.org
Fri Aug 10 11:31:50 EDT 2007


#3: "syntax error before `/' token" when using gcc 3.3.5
------------------------+---------------------------------------------------
 Reporter:  stefan      |       Owner:  somebody
     Type:  defect      |      Status:  new     
 Priority:  normal      |   Milestone:          
Component:  component1  |     Version:          
 Severity:  normal      |    Keywords:          
------------------------+---------------------------------------------------
 Hi,

 when compiling OS with !CppAd/trunk using gcc 3.3.5 I get a strange error
 in the expression {{{(Scalar(int(m)) / ns)}}} appearing in rosen_34.hpp
 line 392 and runge_45.hpp line 352:
 {{{
 In file included from /home/stefan/data/CoinAll-
 trunk/code/cppad/cppad.hpp:30,
                  from
 ../../../../code/OS/src/OSCommonInterfaces/OSnLNode.h:22,
                  from
 ../../../../code/OS/src/OSCommonInterfaces/OSExpressionTree.h:20,
                  from
 ../../../../code/OS/src/OSCommonInterfaces/OSExpressionTree.cpp:18:
 /home/stefan/data/CoinAll-trunk/code/cppad/rosen_34.hpp: In function
 `Vector
    CppAD::Rosen34(Fun&, unsigned int, const Scalar&, const Scalar&, const
    Vector&, Vector&)':
 /home/stefan/data/CoinAll-trunk/code/cppad/rosen_34.hpp:392: error: syntax
    error before `/' token
 In file included from /home/stefan/data/CoinAll-
 trunk/code/cppad/cppad.hpp:31,
                  from
 ../../../../code/OS/src/OSCommonInterfaces/OSnLNode.h:22,
                  from
 ../../../../code/OS/src/OSCommonInterfaces/OSExpressionTree.h:20,
                  from
 ../../../../code/OS/src/OSCommonInterfaces/OSExpressionTree.cpp:18:
 /home/stefan/data/CoinAll-trunk/code/cppad/runge_45.hpp: In function
 `Vector
    CppAD::Runge45(Fun&, unsigned int, const Scalar&, const Scalar&, const
    Vector&, Vector&)':
 /home/stefan/data/CoinAll-trunk/code/cppad/runge_45.hpp:352: error: syntax
    error before `/' token
 }}}

 This seem to be compiler version specific. A workaround it the following:
 {{{
 Index: rosen_34.hpp
 ===================================================================
 --- rosen_34.hpp        (Revision 984)
 +++ rosen_34.hpp        (Arbeitskopie)
 @@ -388,8 +388,9 @@
         xf = xi;           // initialize solution
         for(m = 0; m < M; m++)
         {       // time at beginning of this interval
 +               Scalar m_scalar(int(m));
                 Scalar t = ti * (Scalar(int(M - m)) / ns)
 -                        + tf * (Scalar(int(m)) / ns);
 +                        + tf * (m_scalar / ns);

                 // value of x at beginning of this interval
                 x3 = x4 = xf;
 Index: runge_45.hpp
 ===================================================================
 --- runge_45.hpp        (Revision 984)
 +++ runge_45.hpp        (Arbeitskopie)
 @@ -348,8 +348,9 @@
         for(m = 0; m < M; m++)
         {       // time at beginning of this interval
                 // (convert to int to avoid MS compiler warning)
 +               Scalar m_scalar(int(m));
                 Scalar t = ti * (Scalar(int(M - m)) / ns)
 -                        + tf * (Scalar(int(m)) / ns);
 +                        + tf * (m_scalar / ns);

                 // loop over integration steps
                 x4 = x5 = xf;   // start x4 and x5 at same point for each
 step
 }}}

-- 
Ticket URL: <https://projects.coin-or.org/CppAD/ticket/3>
C++ Algorithmic Differentiation <http://projects.coin-or.org/CppAD>
An algorithmic differentiation library for C++ programs.



More information about the CppAD-tickets mailing list