The following sample code shows a problem with the interaction between
GCC for SPARC 4.0.3 and a Solaris 10 header file. Ultimately, I believe
the fix is going to have to be in the header, changing
typedef struct queue {...} queue_t;
to
typedef struct stream_queue {...} queue_t;
or somesuch, which will be just fine as long as all users of this data
structure have been conscientious enough to use the typedef and not the
raw structure name. However, I do wonder why the Studio Express compiler
does not similarly object.
% which g++
/opt/gcc/bin/g++
% which CC
/opt/SPROexpress/opt/SUNWspro/bin/CC
% g++ --version
sparc-sun-solaris2.10-g++ (GCC) 4.0.3 (gccfss)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
% cat queue.cc
#include <sys/socket.h>
#include <queue>
using std::queue;
% CC -c queue.cc
% g++ -c queue.cc
queue.cc:3: error: 'queue' is already declared in this scope
% # Now let's switch around the order of the lines in the file,
% # to see how that error arises ...
% vi queue.cc
% cat queue.cc
#include <queue>
using std::queue;
#include <sys/socket.h>
% CC -c queue.cc
% g++ -c queue.cc
/usr/include/sys/stream.h:67: error: template argument required for 'struct queue'
/usr/include/sys/stream.h:123: error: invalid type in declaration before ';' token
Thank you for trying gccfss!
> The following sample code shows a problem with the
> interaction between
> GCC for SPARC 4.0.3 and a Solaris 10 header file.
That's actually a user bug.
Here is a simplified testcase:
extern "C" {
struct S {};
}
namespace std
{
template < class _Tp , class _Sequence>
class S{};
}
using std::S;
Both plain g++ and GCCfss g++ correctly produce an error message for the last line.
As you noted there is a conflict between C and stl C++ system header files.
'queue' is just one of the names that is in conflict.
The solution for the user could be to use std::S whenever needed instead of 'using'.
> However, I do wonder why the
> Studio Express compiler
> does not similarly object.
Because Studio C++ compiler has a bug.
For this simplified testcase Studio C++ will not complain (though it should),
but will complain if 'template ...' line is removed. Somehow templatized class hid the name conflict for Studio C++.
I'm seeing a hang (indefinite run time in cg) from a C file that used case ranges.
Here is a test program, reduced down from the file that had the error.
This is with a just downloaded version:
/opt/gcc/bin/gcc -v
Using built-in specs.
Target: sparc-sun-solaris2.10
Configured with: /net/tibia/export/bldmstr/nightly/20060817_mars_gcc.s10.opt.tarbuild/src/configure --prefix=/opt/gcc --enable-shared --with-system-zlib --enable-checking=release --disable-libmudflap --enable-languages=c,c++ --enable-version-specific-runtime-libs --with-gxx-include-dir=/opt/gcc/include/c++/4.0.3 --with-cpu=v9
Thread model: posix
gcc version 4.0.3 (gccfss)
Here is a script that will compile the test program with the default gcc
that comes with Solaris 10 in /opt/gcc/bin/gcc and with the gcc coupled
with the Sun Studio code generator. Of the three compiles in the test
script, the last one will hang.
#!/bin/ksh -x
# works
/usr/sfw/bin/gcc -c \
-DENABLE_case_dot_dot_dot \
show_case_dot_dot_dot_bug.c
# works
/opt/gcc/bin/gcc -c \
-UENABLE_case_dot_dot_dot \
show_case_dot_dot_dot_bug.c
# hangs
/opt/gcc/bin/gcc -c \
-DENABLE_case_dot_dot_dot \
show_case_dot_dot_dot_bug.c
And here is the test program, just one function that
has some case ranges in a switch statement. When
the case ranges are ifdef'ed out, the compile succeeds.
Test file name: show_case_dot_dot_dot_bug.c
typedef struct parameters {
int vectors;
int delay;
int comp;
int format;
int version;
} parameters;
int test(int val, parameters *s)
{
s->format = 200;
switch(val){
case 0x10000000:
s->version= 0;
s->vectors=0;
s->delay=1;
break;
case 0x10002000:
s->version= 3;
s->vectors=1;
s->delay=1;
s->comp=1;
break;
case 0x10003000:
s->version= 3;
s->vectors=1;
s->delay=1;
break;
case 0x10003001:
s->version= 3;
s->vectors=0;
s->delay=1;
break;
case 0x20001000:
#ifdef ENABLE_case_dot_dot_dot
case 0x20100000 ... 0x2019ffff:
#endif
s->delay=1;
break;
#ifdef ENABLE_case_dot_dot_dot
case 0x20200002 ... 0x202fffff:
#endif
case 0x30202002:
case 0x30203002:
s->delay=0;
break;
default:
s->delay=9;
}
return 0;
}
> I'm seeing a hang (indefinite run time in cg) from a
> C file that used case ranges.
Thank you for reporing the problem. The cr number for it is 6481447
We'll provide the fix in a few weeks.
In the mean time could you tell us whether this testcase is from some real application or synthetic test ?
Thank you for the quick reply. I worked around the problem by extracting
the case ranges out of the switch statement and into a if-else proceeding
the switch statement. I thought other people might run into this so it was
worth documenting the problem since they might not know to look for
case ranges in their code.
The testcase code I posted was extracted from one C file in a library of
audio and video encoders and decoders. The C file which had the
compile hang was preprocessed to remove all headers and then
iteratively ifdef'ed out until the function, and then the code, that
caused the compiler hang was located. The code was simplified
some more after that to keep the example small, so that and the
preprocessing might be why it looks like a synthetic test.
> I worked around the problem by extracting the case ranges out of the switch statement and into
> a if-else proceeding the switch statement. I thought other people might
> run into this so it was worth documenting the problem since they might not
> know to look for case ranges in their code.
That is the correct workaround.
The upcoming patch/update will have a fix for this problem. We'll post an announcement when it's available on sdlc website. Hopefully in the next few weeks.
> The upcoming patch/update will have a fix for this
> problem. We'll post an announcement when it's
> available on sdlc website. Hopefully in the next few
> weeks.
We've just released a patch for GCCfss 4.0.3. It's located at the same place place on SDLC website (the link is on the front page).
Please download it, remove old 4.0.3 packages and install new 4.0.3 packages.
This patch contains the fix for the above CG hang with large case ranges plus fixes for other problems reported on the forum.