Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7942 Discussions

Intel Composer XE Update 6 (aka 12.1) and Boost

bsteintrc
Beginner
1,327 Views

I've just installed the latest version of the Intel Composer XE package (Update 6 - technically it was Parallel Studio SP1), otherwise known as 12.1.0 20110811.

When beginning to compile our codebase, I get the following types of errors very early on:

foo.cpp: error #77: this declaration has no storage class or type specifier
BOOST_STATIC_ASSERT(sizeof(CustomType) == 48);
^

foo.cpp: error: expected a ")"
BOOST_STATIC_ASSERT(sizeof(Custom Type) == 48);
^

As well as a number of "error: variable "static_assert" has already been defined"

I've tried searching around, but with no success. This works perfectly fine with the previous version of icc we were using (update 4).

Is this a bug, or do I suddenly need to add in something new?

Thanks.

0 Kudos
19 Replies
Feilong_H_Intel
Employee
1,327 Views
Hi there,

Please let me know the version of your Boost, OS. Also provide a small test case. I'll see if I can reproduce this issue.

Thank you.
--
Feilong H.
Intel Developer Support

Tools Knowledge Base: http://software.intel.com/en-us/articles/tools
0 Kudos
Vladislav__phprus_
1,327 Views
Hello Feilong H.!

Example code:
[cpp]#include 
#include 
int main(int argc, char *argv[])
{
        return 0;
}
[/cpp]
This code isn't compiling. Errors (compiling with "-std=c++0x"):
[plain]/usr/include/boost/smart_ptr/shared_ptr.hpp(614): error: expected an identifier
  template inline bool atomic_is_lock_free( shared_ptr const * /*p*/ )
                                ^
/usr/include/boost/smart_ptr/shared_ptr.hpp(680): error: expected a ";"
  }
  ^
/usr/include/boost/smart_ptr/shared_ptr.hpp(682): error: "atomic_compare_exchange_explicit" is not a function or static data member
  template inline bool atomic_compare_exchange_explicit( shared_ptr * p, shared_ptr * v, shared_ptr w, memory_order /*success*/, memory_order /*failure*/ )
                                ^
/usr/include/boost/smart_ptr/shared_ptr.hpp(698): error: expected a declaration
  } // namespace boost
  ^
/usr/include/boost/date_time/time_clock.hpp(41): error: expected a declaration
      }
      ^
/usr/include/boost/date_time/time_clock.hpp(80): error: expected a declaration
  } } //namespace date_time
  ^
/usr/include/boost/date_time/microsec_time_clock.hpp(53): error: identifier "time_type" is undefined
      static time_type local_time(shared_ptr tz_ptr)
             ^
/usr/include/boost/date_time/microsec_time_clock.hpp(53): error: "local_time" is not a function or static data member
      static time_type local_time(shared_ptr tz_ptr)
                       ^
/usr/include/boost/date_time/microsec_time_clock.hpp(109): error: name followed by "::" must be a class or namespace name
        int adjust = static_cast< int >(resolution_traits_type::res_adjust() / 1000000);
                                        ^
/usr/include/boost/date_time/microsec_time_clock.hpp(111): error: identifier "time_duration_type" is undefined
        time_duration_type td(static_cast< typename time_duration_type::hour_type >(curr_ptr->tm_hour),
        ^
/usr/include/boost/date_time/microsec_time_clock.hpp(111): error: name followed by "::" must be a class or namespace name
        time_duration_type td(static_cast< typename time_duration_type::hour_type >(curr_ptr->tm_hour),
                                                    ^
/usr/include/boost/date_time/microsec_time_clock.hpp(111): error: identifier "curr_ptr" is undefined
        time_duration_type td(static_cast< typename time_duration_type::hour_type >(curr_ptr->tm_hour),
                                                                                    ^
/usr/include/boost/date_time/microsec_time_clock.hpp(111): error: expected a ")"
        time_duration_type td(static_cast< typename time_duration_type::hour_type >(curr_ptr->tm_hour),
                                                                                                      ^
/usr/include/boost/date_time/microsec_time_clock.hpp(116): error: expected a declaration
        return time_type(d,td);
        ^
/usr/include/boost/date_time/microsec_time_clock.hpp(117): error: expected a declaration
      }
      ^
/usr/include/boost/date_time/microsec_time_clock.hpp(121): error: expected a declaration
  } } //namespace date_time
  ^
/usr/include/boost/date_time/time_duration.hpp(45): error: identifier "rep_type" is undefined
      typedef rep_type traits_type;
              ^
/usr/include/boost/date_time/time_duration.hpp(46): error: name followed by "::" must be a class or namespace name
      typedef typename rep_type::day_type  day_type;
                       ^
/usr/include/boost/date_time/time_duration.hpp(47): error: name followed by "::" must be a class or namespace name
      typedef typename rep_type::hour_type hour_type;
                       ^
/usr/include/boost/date_time/time_duration.hpp(48): error: name followed by "::" must be a class or namespace name
      typedef typename rep_type::min_type  min_type;
                       ^
/usr/include/boost/date_time/time_duration.hpp(49): error: name followed by "::" must be a class or namespace name
      typedef typename rep_type::sec_type  sec_type;
                       ^
/usr/include/boost/date_time/time_duration.hpp(50): error: name followed by "::" must be a class or namespace name
      typedef typename rep_type::fractional_seconds_type fractional_seconds_type;
                       ^
/usr/include/boost/date_time/time_duration.hpp(51): error: name followed by "::" must be a class or namespace name
      typedef typename rep_type::tick_type tick_type;
                       ^
/usr/include/boost/date_time/time_duration.hpp(52): error: name followed by "::" must be a class or namespace name
      typedef typename rep_type::impl_type impl_type;
                       ^
/usr/include/boost/date_time/time_duration.hpp(54): error: expected a "{"
      time_duration() : ticks_(0) {}
                      ^
/usr/include/boost/date_time/time_duration.hpp(58): error: expected a "{"
                    fractional_seconds_type frac_sec_in = 0) :
                                                             ^
/usr/include/boost/date_time/time_duration.hpp(63): error: overloaded function "time_duration" is not a template
      time_duration(const time_duration& other)
                          ^
/usr/include/boost/date_time/time_duration.hpp(63): error: identifier "T" is undefined
      time_duration(const time_duration& other)
                                        ^
/usr/include/boost/date_time/time_duration.hpp(63): error: identifier "rep_type" is undefined
      time_duration(const time_duration& other)
                                           ^
/usr/include/boost/date_time/time_duration.hpp(64): error: expected a "{"
        : ticks_(other.ticks_)
        ^
/usr/include/boost/date_time/time_duration.hpp(67): error: identifier "special_values" is undefined
      time_duration(special_values sv) : ticks_(impl_type::from_special(sv))
                    ^
/usr/include/boost/date_time/time_duration.hpp(67): error: expected a "{"
      time_duration(special_values sv) : ticks_(impl_type::from_special(sv))
                                       ^
/usr/include/boost/date_time/time_duration.hpp(70): error: identifier "duration_type" is undefined
      static duration_type unit()
             ^
/usr/include/boost/date_time/time_duration.hpp(72): error: identifier "duration_type" is undefined
        return duration_type(0,0,0,1);
               ^
/usr/include/boost/date_time/time_duration.hpp(77): error: name followed by "::" must be a class or namespace name
        return rep_type::res_adjust();
               ^
/usr/include/boost/date_time/time_duration.hpp(80): error: identifier "time_resolutions" is undefined
      static time_resolutions resolution()
             ^
/usr/include/boost/date_time/time_duration.hpp(82): error: name followed by "::" must be a class or namespace name
        return rep_type::resolution();
               ^
/usr/include/boost/date_time/time_duration.hpp(85): error: a type qualifier is not allowed on a nonmember function
      hour_type hours()   const
                          ^
/usr/include/boost/date_time/time_duration.hpp(87): error: identifier "ticks" is undefined
        return static_cast(ticks() / (3600*ticks_per_second()));
                                      ^
/usr/include/boost/date_time/time_duration.hpp(90): error: a type qualifier is not allowed on a nonmember function
      min_type minutes() const
                         ^
/usr/include/boost/date_time/time_duration.hpp(92): error: identifier "ticks" is undefined
        return static_cast((ticks() / (60*ticks_per_second())) % 60);
                                      ^
/usr/include/boost/date_time/time_duration.hpp(95): error: a type qualifier is not allowed on a nonmember function
      sec_type seconds() const
                         ^
/usr/include/boost/date_time/time_duration.hpp(97): error: identifier "ticks" is undefined
        return static_cast((ticks()/ticks_per_second()) % 60);
                                      ^
/usr/include/boost/date_time/time_duration.hpp(100): error: a type qualifier is not allowed on a nonmember function
      sec_type total_seconds() const
                               ^
/usr/include/boost/date_time/time_duration.hpp(102): error: identifier "ticks" is undefined
        return static_cast(ticks() / ticks_per_second());
                                     ^
/usr/include/boost/date_time/time_duration.hpp(105): error: a type qualifier is not allowed on a nonmember function
      tick_type total_milliseconds() const
                                     ^
/usr/include/boost/date_time/time_duration.hpp(108): error: identifier "ticks" is undefined
          return ticks() * (static_cast(1000) / ticks_per_second());
                 ^
/usr/include/boost/date_time/time_duration.hpp(110): error: identifier "ticks" is undefined
        return ticks() / (ticks_per_second() / static_cast(1000)) ;
               ^
/usr/include/boost/date_time/time_duration.hpp(113): error: a type qualifier is not allowed on a nonmember function
      tick_type total_nanoseconds() const
                                    ^
/usr/include/boost/date_time/time_duration.hpp(116): error: identifier "ticks" is undefined
          return ticks() * (static_cast(1000000000) / ticks_per_second());
                 ^
/usr/include/boost/date_time/time_duration.hpp(118): error: identifier "ticks" is undefined
        return ticks() / (ticks_per_second() / static_cast(1000000000)) ;
               ^
/usr/include/boost/date_time/time_duration.hpp(121): error: a type qualifier is not allowed on a nonmember function
      tick_type total_microseconds() const
                                     ^
/usr/include/boost/date_time/time_duration.hpp(124): error: identifier "ticks" is undefined
          return ticks() * (static_cast(1000000) / ticks_per_second());
                 ^
/usr/include/boost/date_time/time_duration.hpp(126): error: identifier "ticks" is undefined
        return ticks() / (ticks_per_second() / static_cast(1000000)) ;
               ^
/usr/include/boost/date_time/time_duration.hpp(129): error: a type qualifier is not allowed on a nonmember function
      fractional_seconds_type fractional_seconds() const
                                                   ^
/usr/include/boost/date_time/time_duration.hpp(131): error: identifier "ticks" is undefined
        return (ticks() % ticks_per_second());
                ^
/usr/include/boost/date_time/time_duration.hpp(136): error: name followed by "::" must be a class or namespace name
        return rep_type::num_fractional_digits();
               ^
/usr/include/boost/date_time/time_duration.hpp(138): error: identifier "duration_type" is undefined
      duration_type invert_sign() const
      ^
/usr/include/boost/date_time/time_duration.hpp(138): error: a type qualifier is not allowed on a nonmember function
      duration_type invert_sign() const
                                  ^
/usr/include/boost/date_time/time_duration.hpp(140): error: identifier "ticks_" is undefined
        return duration_type(ticks_ * (-1));
                             ^
/usr/include/boost/date_time/time_duration.hpp(140): error: identifier "duration_type" is undefined
        return duration_type(ticks_ * (-1));
               ^
/usr/include/boost/date_time/time_duration.hpp(142): error: a type qualifier is not allowed on a nonmember function
      bool is_negative() const
                         ^
/usr/include/boost/date_time/time_duration.hpp(144): error: identifier "ticks_" is undefined
        return ticks_ < 0;
               ^
/usr/include/boost/date_time/time_duration.hpp(146): error: overloaded function "time_duration" is not a type name
      bool operator<(const time_duration& rhs)  const
                           ^
/usr/include/boost/date_time/time_duration.hpp(146): error: a type qualifier is not allowed on a nonmember function
      bool operator<(const time_duration& rhs)  const
                                                ^
/usr/include/boost/date_time/time_duration.hpp(146): error: too few parameters for this operator function
      bool operator<(const time_duration& rhs)  const
           ^
/usr/include/boost/date_time/time_duration.hpp(146): error: nonmember operator requires a parameter with class or enum type
      bool operator<(const time_duration& rhs)  const
           ^
/usr/include/boost/date_time/time_duration.hpp(148): error: identifier "ticks_" is undefined
        return ticks_ <  rhs.ticks_;
               ^
/usr/include/boost/date_time/time_duration.hpp(150): error: overloaded function "time_duration" is not a type name
      bool operator==(const time_duration& rhs)  const
                            ^
/usr/include/boost/date_time/time_duration.hpp(150): error: a type qualifier is not allowed on a nonmember function
      bool operator==(const time_duration& rhs)  const
                                                 ^
/usr/include/boost/date_time/time_duration.hpp(150): error: too few parameters for this operator function
      bool operator==(const time_duration& rhs)  const
           ^
/usr/include/boost/date_time/time_duration.hpp(150): error: nonmember operator requires a parameter with class or enum type
      bool operator==(const time_duration& rhs)  const
           ^
/usr/include/boost/date_time/time_duration.hpp(152): error: identifier "ticks_" is undefined
        return ticks_ ==  rhs.ticks_;
               ^
/usr/include/boost/date_time/time_duration.hpp(155): error: identifier "duration_type" is undefined
      duration_type operator-()const
      ^
/usr/include/boost/date_time/time_duration.hpp(155): error: a type qualifier is not allowed on a nonmember function
      duration_type operator-()const
                               ^
/usr/include/boost/date_time/time_duration.hpp(155): error: too few parameters for this operator function
      duration_type operator-()const
                    ^
/usr/include/boost/date_time/time_duration.hpp(155): error: nonmember operator requires a parameter with class or enum type
      duration_type operator-()const
                    ^
/usr/include/boost/date_time/time_duration.hpp(157): error: identifier "ticks_" is undefined
        return duration_type(ticks_ * (-1));
                             ^
/usr/include/boost/date_time/time_duration.hpp(157): error: identifier "duration_type" is undefined
        return duration_type(ticks_ * (-1));
               ^
/usr/include/boost/date_time/time_duration.hpp(159): error: identifier "duration_type" is undefined
      duration_type operator-(const duration_type& d) const
      ^
/usr/include/boost/date_time/time_duration.hpp(159): error: identifier "duration_type" is undefined
      duration_type operator-(const duration_type& d) const
                                    ^
/usr/include/boost/date_time/time_duration.hpp(159): error: a type qualifier is not allowed on a nonmember function
      duration_type operator-(const duration_type& d) const
                                                      ^
/usr/include/boost/date_time/time_duration.hpp(159): error: nonmember operator requires a parameter with class or enum type
      duration_type operator-(const duration_type& d) const
                    ^
/usr/include/boost/date_time/time_duration.hpp(161): error: identifier "ticks_" is undefined
        return duration_type(ticks_ - d.ticks_);
                             ^
/usr/include/boost/date_time/time_duration.hpp(161): error: identifier "duration_type" is undefined
        return duration_type(ticks_ - d.ticks_);
               ^
/usr/include/boost/date_time/time_duration.hpp(163): error: identifier "duration_type" is undefined
      duration_type operator+(const duration_type& d) const
      ^
/usr/include/boost/date_time/time_duration.hpp(163): error: identifier "duration_type" is undefined
      duration_type operator+(const duration_type& d) const
                                    ^
/usr/include/boost/date_time/time_duration.hpp(163): error: a type qualifier is not allowed on a nonmember function
      duration_type operator+(const duration_type& d) const
                                                      ^
/usr/include/boost/date_time/time_duration.hpp(163): error: nonmember operator requires a parameter with class or enum type
      duration_type operator+(const duration_type& d) const
                    ^
/usr/include/boost/date_time/time_duration.hpp(165): error: identifier "ticks_" is undefined
        return duration_type(ticks_ + d.ticks_);
                             ^
/usr/include/boost/date_time/time_duration.hpp(165): error: identifier "duration_type" is undefined
        return duration_type(ticks_ + d.ticks_);
               ^
/usr/include/boost/date_time/time_duration.hpp(167): error: identifier "duration_type" is undefined
      duration_type operator/(int divisor) const
      ^
/usr/include/boost/date_time/time_duration.hpp(167): error: a type qualifier is not allowed on a nonmember function
      duration_type operator/(int divisor) const
                                           ^
/usr/include/boost/date_time/time_duration.hpp(167): error: too few parameters for this operator function
      duration_type operator/(int divisor) const
                    ^
/usr/include/boost/date_time/time_duration.hpp(167): error: nonmember operator requires a parameter with class or enum type
      duration_type operator/(int divisor) const
                    ^
/usr/include/boost/date_time/time_duration.hpp(169): error: identifier "ticks_" is undefined
        return duration_type(ticks_ / divisor);
                             ^
/usr/include/boost/date_time/time_duration.hpp(169): error: identifier "duration_type" is undefined
        return duration_type(ticks_ / divisor);
               ^
/usr/include/boost/date_time/time_duration.hpp(171): error: identifier "duration_type" is undefined
      duration_type operator-=(const duration_type& d)
      ^
/usr/include/boost/date_time/time_duration.hpp(171): error: identifier "duration_type" is undefined
      duration_type operator-=(const duration_type& d)
                                     ^
/usr/include/boost/date_time/time_duration.hpp(171): error: too few parameters for this operator function
      duration_type operator-=(const duration_type& d)
                    ^
compilation aborted for icctest.cpp (code 4)[/plain]

Boost: 1.47.0
OS: openSUSE 11.4 x86-64
GCC 4.5.1

But this is only a small fraction of all errors that occurred when using the compiler 12.1.0.

Discussion in Russian: http://forum.vingrad.ru/forum/topic-337964.html
0 Kudos
bsteintrc
Beginner
1,327 Views
Whoops, I did forget to include the boost version. Apologies.
It happens with very simple code, and on all of our systems, from RHEL4 to FC14.


boost.cc
[cpp]#include 

BOOST_STATIC_ASSERT(sizeof(char) == 1);

int main(int argc, char* argv[])
{
  return 0;
}
[/cpp]


The compile line is similarly simple:
icpc -c -xc++ -O0 -g -I"/path/to/boost/install/include/boost_1_46_1" -c -o boost.o boost.cc

To which it spits out:
[plain]boost.cc(3): error #77: this declaration has no storage class or type specifier
  BOOST_STATIC_ASSERT(sizeof(char) == 1);
  ^

boost.cc(3): error: expected a ")"
  BOOST_STATIC_ASSERT(sizeof(char) == 1);
  ^

compilation aborted for boost.cc (code 2)[/plain]

It works perfectly fine with icc12 update 4.

I can provide the full -E output, if you'd like.
0 Kudos
bsteintrc
Beginner
1,327 Views
Any updates here?
0 Kudos
Judith_W_Intel
Employee
1,327 Views

Please post the preprocessed (-E) output. BOOST_STATIC_ASSERT is a macro that can expand to many different things...
0 Kudos
bsteintrc
Beginner
1,327 Views
See attached.
Generated by
icc boost.cc -E -o boost.p
0 Kudos
Feilong_H_Intel
Employee
1,327 Views
Thanks for the preprocessed file. However, I can't reproduce the problem with it. I think it is becase you removed some compiler options when preprocessing the source code. Obviously, you dropped -std=c++0x, and probably some other options.

Could you please just replace -c with -E in your compilation command line to generate a preprocessed file?

Thanks,
Feilong
0 Kudos
Vladislav__phprus_
1,327 Views
Steps to reproduce the problem:
1) Install openSUSE 11.4 x86-64.
2) Build Boost 1.47.0:
[bash]./bootstrap.sh --with-toolset=gcc --prefix=/home/phprus/opt/icmm/boost/1.47.0/gcc
./b2 --layout=tagged -j2 variant=release threading=multi runtime-link=shared stage
./b2 --layout=tagged -j2 variant=release threading=multi runtime-link=shared link=shared install[/bash]
3) Install Intel composer xe 12.1.0 64-bit.
4) Build source:
[cpp]#include 
#include 

int main(int argc, char *argv[])
{
	return 0;
}
[/cpp]
command: "icpc -I/home/phprus/opt/icmm/boost/1.47.0/gcc/include -L/home/phprus/opt/icmm/boost/1.47.0/gcc/lib -lboost_system-mt -o icctest icctest.cpp"

List of errors in the file boost_errors.txt and the result of preprocessing in file boost_pre.txt
0 Kudos
bsteintrc
Beginner
1,327 Views
Whoops, you're right; my apologies.
In my haste, I forgot to add the -I to our boost install.
As it happens, that's the only one that's necessary:
icpc -I"/path/to/boost" -c -o boost.o boost.cc
will still fail with the same error.

But, here's the one from the more complete:
icpc -c -xc++ -O0 -g -I"/path/to/boost/install/include/boost_1_46_1" -E -o boost.P boost.cc
0 Kudos
Judith_W_Intel
Employee
1,327 Views

It looks like the code contains the C++0x static_assert declaration but you're not using the -std=c++0x
option, i.e.:

sptxl8-1332> icpc -c boost.cpp
boost.cc(3): error #77: this declaration has no storage class or type specifier
static_assert(sizeof(char) == 1, "sizeof(char) == 1");
^

boost.cc(3): error: expected a ")"
static_assert(sizeof(char) == 1, "sizeof(char) == 1");
^

compilation aborted for boost.cpp (code 2)
sptxl8-1333> icpc -c -std=c++0x boost.cpp
sptxl8-1334>

You would have the same problem if you used g++.

0 Kudos
bsteintrc
Beginner
1,327 Views
I'm sorry to be so blunt, but that's completely incorrect.
I specifically stated in my initial post that it works fine with Update 4 (12.0.4 20110427). I didn't mention gcc, but it also works perfectly fine there, as well. The original code that caused the problem has been building fine for months, it only came up when I installed 12.1, and tried to build the code. I specifically don't want to add -std=c++0x since other parts of our code begin to have issues.

For reference, here are the preprocessor outputs from icpc 12.0.4, and g++ 4.1.2, using the following commands:
icpc -I"/apps/infra/environ/20110323/common/include/boost_1_46_1" -E -o boost.icc.P boost.cc
boost.icc.P
g++ -I"/apps/infra/environ/20110323/common/include/boost_1_46_1" -E -o boost.gcc.P boost.cc
boost.gcc.P

If the static_assert declaration is getting in there, it's because of something the 12.1 preprocessor is doing, not me.
0 Kudos
Judith_W_Intel
Employee
1,327 Views
> If the static_assert declaration is getting in there, it's because of something the 12.1 preprocessor is doing, not me.

The preprocessed file you attached will not work with 12.0 unless you use the -std=c++0x option.

As I stated before, the BOOST_STATIC_ASSERT macro can expand to different things based upon configuration macros that the Boost header files uses. So if you don't like the way these macros are beingexpanded please complain to the maintainers of the Boost library.

I see this in the static_assert.hpp header:

#ifndef BOOST_NO_STATIC_ASSERT
# define BOOST_STATIC_ASSERT_MSG( B, Msg ) static_assert(B, Msg)
#else
# define BOOST_STATIC_ASSERT_MSG( B, Msg ) BOOST_STATIC_ASSERT( B )
#endif

So it looks like the config.hpp that got created when you did the configuration setup for Boost
detected that the C++0x static_assert feature was available and set BOOST_NO_STATIC_ASSERT to FALSE.

When you ran the Boostconfiguration script (which creates config.hpp) did you use the -std=c++0x option?

Judy
0 Kudos
bsteintrc
Beginner
1,327 Views
You're right, it won't compile with 12.0. And the 12.0 preprocessor output will compile with 12.1.
But I definitely didn't pass -std=c++0x when I configured boost.
And you can see from the other attachments that the 12.0 preprocessor output has this macro expanded differently (and properly).
I've also tried with icc 11.1 (20101201) and it works fine. The preprocessor output is identical to that of the 12.0 one, except for commented header locations.

So I now have three compilers (icc 12.0, icc 11.1, gcc) that work identically (and correctly) with the *exact same* compile arguments (including -std=c++), and one compiler (icc 12.1) that fails. It's the *same* boost installation, so it's not a configuration issue.

We've had the same copy of boost installed for the past 6 months, used with several different compilers, including two different versions of the intel compiler. None of them have any problem. The only thing that's been added has been intel 12.1, and it starts having an issue. Yet it's somehow boost's fault? Vlad has reported a similar issue, and that's with a fresh build of boost, no c++0x.

At the very least it's producing something substantially different than the previous version, and the only thing that has changed is the compiler. I would expect it to be backwards compatible.
0 Kudos
bsteintrc
Beginner
1,327 Views
Your mention of configuration files and definitions got me thinking.
On a whim, I made a simple program:

[cpp]int test1 = __INTEL_COMPILER;
int test2 = __ICC;
int test3 = __INTEL_COMPILER_BUILD_DATE;
int test4 = __VERSION__;


int main(int argc, char* argv[])
{
return 0;
}
[/cpp]

And ran it through the preprocessor to see what some builtin values were. (I couldn't think of a better way).
My command wasn't anything fancy, just:
icpc -E -o vars.P vars.cc

When run with icc 12.0, I get values I expect:
[cpp]# 1 "test.cc"

int test1 = 1200;
int test2 = 1200;
int test3 = 20110427;
int test4 = "Intel C++ g++ 3.4 mode";


int main(int argc, char* argv[])
{
return 0;
}
[/cpp]

When I run it with icc 12.1, I don't:

[cpp]# 1 "test.cc"


int test1 = 9999;
int test2 = 9999;
int test3 = 20110811;
int test4 = "Intel C++ g++ 3.4 mode";


int main(int argc, char* argv[])
{
return 0;
}
[/cpp]

I'm guessing this is the culprit.
How long before we can expect a fix? If it hadn't been boost that failed first, I might have noticed it from some of the other pieces of our code that check compiler version info. But I can't believe we're the only place that checks versions of things.
0 Kudos
Judith_W_Intel
Employee
1,327 Views

I looked in the file:

boost/config/compiler/intel.hpp

and I see
// C++0x features
// - ICC added static_assert in 11.0 (first version with C++0x support)
//
#if defined(BOOST_INTEL_STDCXX0X)
# undef BOOST_NO_STATIC_ASSERT
...

So I then looked to see why BOOST_INTEL_STDCXX0X would be defined even when
you don't specify -std=c++0x.

I see this:

#if (!(defined(_WIN32) || defined(_WIN64)) &&
defined(__STDC_HOSTED__) && __STDC_HOSTED__) ||
defined(__GXX_EXPERIMENTAL_CPP0X__)
# define BOOST_INTEL_STDCXX0X
#endif
#if defined(_MSC_VER) && (_MSC_VER >= 1600)
# define BOOST_INTEL_STDCXX0X
#endif

The Intel compiler (this is new in 12.1) defines __STDC_HOSTED__ to 1.
This is to be compatible with Gnu. Simply a bug fix.
Boost should not assume that you have turned on the -std=c++0x option
just because this macro is defined. They should only use the
__GXX_EXPERIMENTAL_CPP0X__ macro. The __GXX_EXPERIMENTAL_CPP0X__
is defined by both our compiler and Gnu if the user uses the
-std=c++0x option and the GNU version being used is 4.5 and earlier.

So I think that is the difference here.

If you want to disable the static_assert feature in Boost I think you can
edit the file boost/config/compiler/intel.hpp

and comment out the line that says:

# undef BOOST_NO_STATIC_ASSERT

Of if you want to go back to 12.0 behaviour add -U__STDC_HOSTED__ to your
command line.

This is what I see in the boost/config/compiler/gcc.hpp file which
looks like it should have been used for Intel too:

#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 2)) &&
defined(__GXX_EXPERIMENTAL_CXX0X__)
// C++0x features are only enabled when -std=c++0x or -std=gnu++0x are
// passed on the command line, which in turn defines
// __GXX_EXPERIMENTAL_CXX0X__.
# define BOOST_HAS_DECLTYPE
# define BOOST_HAS_RVALUE_REFS
# define BOOST_HAS_STATIC_ASSERT
# define BOOST_HAS_VARIADIC_TMPL

I would complain to Boost... looks like they have a bug here.

Judy

P.S. The output for __INTEL_COMPILER and __ICC does look wrong. I can't reproduce that problem using my development compiler, i.e.:

sptxl8-30> cat macro.cpp

int test1 = __INTEL_COMPILER;
int test2 = __ICC;
int test3 = __INTEL_COMPILER_BUILD_DATE;
int test4 = __VERSION__;

int main(int argc, char* argv[]) {
return 0;
}

sptxl8-31> icpc -xc++ -c -E macro.cpp
# 1 "macro.cpp"

int test1 = 1210;
int test2 = 1210;
int test3 = 20110921;
int test4 = "Intel C++ g++ 4.1 mode";

int main(int argc, char* argv[]) {
return 0;
}

Perhaps one of the Intel support folks can try a released compiler?

0 Kudos
Vladislav__phprus_
1,327 Views
Your analysis has helped to rectify an error in Boost which was shown without usage "-std=c++0x" in case of usage static_assert. For this purpose it is necessary to use an applied patch for Boost.

But it hasn't solved my problem in case of usage boost::shared_ptr and boost::asio at included "-std=c++0x".
Apparently at a stage of preprocessing the compiler it is irreversible damages determinations of the functions which names coincide with functions from the new standard, without paying attention to name spaces.
Result of preprocessing and the list of errors I apply.
0 Kudos
Judith_W_Intel
Employee
1,327 Views

The problem in the last reply (posted by Vladislva) does look to be a problem with pollution of the global scope with macro definitions in the Intel header file .

If you look at the preprocessed file instead of:

template inline bool atomic_is_lock_free( shared_ptr const * /*p*/

the preprocessed output looks like:

template inline bool true

which of course gets syntax errors from the compiler.

The culprit looks to be the header file /opt/intel/composer_xe_2011_sp1.6.233/compiler/include/stdatomic.h
where I see macros like:

#define atomic_is_lock_free(a) \
true
#define atomic_store(a, n) \
__atomic_store_explicit(&(a)->_Val, (n), memory_order_seq_cst)
etc.

I have entered a bug report (cq #174102) for the Intel engineers responsible for this header to fix the problem.

In the meantime, a possible workaround is to ensure thatBOOST_ASIO_HAS_STD_ATOMIC is not defined.
I would tryadding -DBOOST_ASIO_DISABLE_STD_ATOMIC to the command line.

Judy
0 Kudos
bsteintrc
Beginner
1,327 Views
Unfortunately, I can't add -U__STDC_HOSTED__ to my command line, I get the following error:

Command-line error: invalid macro undefinition: __STDC_HOSTED__
compilation aborted for boost.cc (code 4)

On the other hand, you're right that when I add
#undef __STDC_HOSTED__
SHARED_INSTALLSHARED_INSTALL

right before the boost include, it compiles without error.
I don't think I would ever have noticed __STD_HOSTED__.


0 Kudos
bsteintrc
Beginner
1,327 Views
Was there any resolution to this? I'd love to be able to add -U__STDC_HOSTED__ as a fix, so that I don't need to modify all our source files, but it seems strange to me that I can't undefine a variable that's automatically defined by the compiler.
0 Kudos
Reply