Discussion:
[Crystal-develop] [Crystal-cvs] SF.net SVN: crystal:[39815] CS/trunk/include/csgeom/spatialtree.h
res
2013-09-30 17:37:45 UTC
Permalink
The static variable isn't allocated space anywhere so applications linking
to the CS library fail to link.
I didn't see a good place to define it so I did the easy thing and used a
constant.
@@ -415,7 +415,6 @@
int numObjects; // current storage used
int maxObjects; // current storage capacity
int estimateObjects; // estimated number of objects in whole tree
- static int const objectGrowth = 80; // storage growth minimum
// Minimum amount of objects in this tree before we consider splitting.
int minSplitObjects;
I think it's a thing that works in C++11 (becomes a “true“ constant
there), but it results in the static var prob you see above with C++03.
There the workaround is to use an enum:
enum { objectGrowth = 80 };

-f.r.
Ralph Campbell
2013-09-30 18:06:51 UTC
Permalink
I tried that first actually.
Switching to an enum doesn't work because csMin() is defined to use
references to T and at least gcc 4.8.1 is gets confused what type to
use for the template (int or enum).
Doing "maxObjects += csMin(maxObjects+2, (int)objectGrowth);"
seems to work though.
The static variable isn't allocated space anywhere so applications linking
to the CS library fail to link.
I didn't see a good place to define it so I did the easy thing and used a
constant.
@@ -415,7 +415,6 @@
int numObjects; // current storage used
int maxObjects; // current storage capacity
int estimateObjects; // estimated number of objects in whole tree
- static int const objectGrowth = 80; // storage growth minimum
// Minimum amount of objects in this tree before we consider splitting.
int minSplitObjects;
I think it's a thing that works in C++11 (becomes a “true“ constant
there), but it results in the static var prob you see above with C++03.
enum { objectGrowth = 80 };
-f.r.
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk
_______________________________________________
Crystal-develop mailing list
https://lists.sourceforge.net/lists/listinfo/crystal-develop
Matthieu Kraus
2013-09-30 20:32:17 UTC
Permalink
You can go with an enum then, but please don't use such a c-style
cast, either use static_cast<int> or use csMin<int> - the code in
question here is very clean in that regard and I'd really appreciate
if it stays that way.

Question though: does that only break with 4.8.x and does it work in
c++11 mode? Because it worked fine for me with VS10 and gcc 4.4.7, so
if it's only such a recent version where it breaks and if it only
breaks in c++03 mode I'm not sure it's actually worth working around
as you should be using c++11 mode with the newer gcc versions, anyway.

kind regards,
RlyDontKnow
Post by Ralph Campbell
I tried that first actually.
Switching to an enum doesn't work because csMin() is defined to use
references to T and at least gcc 4.8.1 is gets confused what type to
use for the template (int or enum).
Doing "maxObjects += csMin(maxObjects+2, (int)objectGrowth);"
seems to work though.
The static variable isn't allocated space anywhere so applications linking
to the CS library fail to link.
I didn't see a good place to define it so I did the easy thing and used a
constant.
@@ -415,7 +415,6 @@
int numObjects; // current storage used
int maxObjects; // current storage capacity
int estimateObjects; // estimated number of objects in whole tree
- static int const objectGrowth = 80; // storage growth minimum
// Minimum amount of objects in this tree before we consider
splitting.
int minSplitObjects;
I think it's a thing that works in C++11 (becomes a “true“ constant
there), but it results in the static var prob you see above with C++03.
enum { objectGrowth = 80 };
-f.r.
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk
_______________________________________________
Crystal-develop mailing list
https://lists.sourceforge.net/lists/listinfo/crystal-develop
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk
_______________________________________________
Crystal-develop mailing list
https://lists.sourceforge.net/lists/listinfo/crystal-develop
Eric Sunshine
2013-09-30 21:27:23 UTC
Permalink
On Mon, Sep 30, 2013 at 4:32 PM, Matthieu Kraus
Post by Matthieu Kraus
You can go with an enum then, but please don't use such a c-style
cast, either use static_cast<int> or use csMin<int> - the code in
question here is very clean in that regard and I'd really appreciate
if it stays that way.
Question though: does that only break with 4.8.x and does it work in
c++11 mode? Because it worked fine for me with VS10 and gcc 4.4.7, so
if it's only such a recent version where it breaks and if it only
breaks in c++03 mode I'm not sure it's actually worth working around
as you should be using c++11 mode with the newer gcc versions, anyway.
Some people are stuck at whatever compiler version is supplied by
their vendor (think Apple and Xcode), so we shouldn't necessarily
assume that using a newer gcc version is an easy option. With a simple
work-around as we have available here (using one of the syntaxes you
suggest above), we should apply it.

-- ES
Post by Matthieu Kraus
kind regards,
RlyDontKnow
Post by Ralph Campbell
I tried that first actually.
Switching to an enum doesn't work because csMin() is defined to use
references to T and at least gcc 4.8.1 is gets confused what type to
use for the template (int or enum).
Doing "maxObjects += csMin(maxObjects+2, (int)objectGrowth);"
seems to work though.
The static variable isn't allocated space anywhere so applications linking
to the CS library fail to link.
I didn't see a good place to define it so I did the easy thing and used a
constant.
@@ -415,7 +415,6 @@
int numObjects; // current storage used
int maxObjects; // current storage capacity
int estimateObjects; // estimated number of objects in whole tree
- static int const objectGrowth = 80; // storage growth minimum
// Minimum amount of objects in this tree before we consider
splitting.
int minSplitObjects;
I think it's a thing that works in C++11 (becomes a “true“ constant
there), but it results in the static var prob you see above with C++03.
enum { objectGrowth = 80 };
-f.r.
Matthieu Kraus
2013-10-01 09:05:42 UTC
Permalink
I wasn't assuming that a specific gcc version was present, merely
asking whether the issue only arose in c++03 mode for new gcc versions
which support c++11 as it didn't show in an old one (in my case I
tested with 4.4.7 which is what RHEL 6 comes with) and as res stated
some of the rules applying to static member initialization and const
expressions changed in c++11.
Post by Eric Sunshine
On Mon, Sep 30, 2013 at 4:32 PM, Matthieu Kraus
Post by Matthieu Kraus
You can go with an enum then, but please don't use such a c-style
cast, either use static_cast<int> or use csMin<int> - the code in
question here is very clean in that regard and I'd really appreciate
if it stays that way.
Question though: does that only break with 4.8.x and does it work in
c++11 mode? Because it worked fine for me with VS10 and gcc 4.4.7, so
if it's only such a recent version where it breaks and if it only
breaks in c++03 mode I'm not sure it's actually worth working around
as you should be using c++11 mode with the newer gcc versions, anyway.
Some people are stuck at whatever compiler version is supplied by
their vendor (think Apple and Xcode), so we shouldn't necessarily
assume that using a newer gcc version is an easy option. With a simple
work-around as we have available here (using one of the syntaxes you
suggest above), we should apply it.
-- ES
Post by Matthieu Kraus
kind regards,
RlyDontKnow
Post by Ralph Campbell
I tried that first actually.
Switching to an enum doesn't work because csMin() is defined to use
references to T and at least gcc 4.8.1 is gets confused what type to
use for the template (int or enum).
Doing "maxObjects += csMin(maxObjects+2, (int)objectGrowth);"
seems to work though.
The static variable isn't allocated space anywhere so
applications linking
to the CS library fail to link.
I didn't see a good place to define it so I did the easy thing
and used a
constant.
@@ -415,7 +415,6 @@
int numObjects; // current storage used
int maxObjects; // current storage capacity
int estimateObjects; // estimated number of objects in whole tree
- static int const objectGrowth = 80; // storage growth minimum
// Minimum amount of objects in this tree before we consider
splitting.
int minSplitObjects;
I think it's a thing that works in C++11 (becomes a “true“ constant
there), but it results in the static var prob you see above with C++03.
enum { objectGrowth = 80 };
-f.r.
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
_______________________________________________
Crystal-develop mailing list
https://lists.sourceforge.net/lists/listinfo/crystal-develop
Eric Sunshine
2013-10-01 09:22:57 UTC
Permalink
Thanks for the clarification. I may have focused too narrowly on "I'm not sure it's actually worth working around" without comprehending more fully. I didn't mean to negate your question.

I can report that over many years, I have run into trouble with many compilers (and compiler versions) on many platforms with these constant integers. Way back, it was enough to declare them as 'const int', then some compilers tightened that to 'static const int', but that didn't work everywhere. The only common denominator was 'enum', which worked on all compilers across all versions across all platforms. In CS, we have always made the extra effort to work around localized problems, such as this one, so it seemed sensible to recommend continuing to do so.

-- ES
Post by Matthieu Kraus
I wasn't assuming that a specific gcc version was present, merely
asking whether the issue only arose in c++03 mode for new gcc versions
which support c++11 as it didn't show in an old one (in my case I
tested with 4.4.7 which is what RHEL 6 comes with) and as res stated
some of the rules applying to static member initialization and const
expressions changed in c++11.
Post by Eric Sunshine
On Mon, Sep 30, 2013 at 4:32 PM, Matthieu Kraus
Post by Matthieu Kraus
You can go with an enum then, but please don't use such a c-style
cast, either use static_cast<int> or use csMin<int> - the code in
question here is very clean in that regard and I'd really appreciate
if it stays that way.
Question though: does that only break with 4.8.x and does it work in
c++11 mode? Because it worked fine for me with VS10 and gcc 4.4.7, so
if it's only such a recent version where it breaks and if it only
breaks in c++03 mode I'm not sure it's actually worth working around
as you should be using c++11 mode with the newer gcc versions, anyway.
Some people are stuck at whatever compiler version is supplied by
their vendor (think Apple and Xcode), so we shouldn't necessarily
assume that using a newer gcc version is an easy option. With a simple
work-around as we have available here (using one of the syntaxes you
suggest above), we should apply it.
-- ES
Post by Matthieu Kraus
kind regards,
RlyDontKnow
Post by Ralph Campbell
I tried that first actually.
Switching to an enum doesn't work because csMin() is defined to use
references to T and at least gcc 4.8.1 is gets confused what type to
use for the template (int or enum).
Doing "maxObjects += csMin(maxObjects+2, (int)objectGrowth);"
seems to work though.
The static variable isn't allocated space anywhere so
applications linking
to the CS library fail to link.
I didn't see a good place to define it so I did the easy thing
and used a
constant.
@@ -415,7 +415,6 @@
int numObjects; // current storage used
int maxObjects; // current storage capacity
int estimateObjects; // estimated number of objects in whole tree
- static int const objectGrowth = 80; // storage growth minimum
// Minimum amount of objects in this tree before we consider
splitting.
int minSplitObjects;
I think it's a thing that works in C++11 (becomes a “true“ constant
there), but it results in the static var prob you see above with C++03.
enum { objectGrowth = 80 };
-f.r.
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
_______________________________________________
Crystal-develop mailing list
https://lists.sourceforge.net/lists/listinfo/crystal-develop
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
_______________________________________________
Crystal-develop mailing list
https://lists.sourceforge.net/lists/listinfo/crystal-develop
Matthieu Kraus
2013-10-01 18:32:58 UTC
Permalink
Can you please explain me again how and where the issue arose?
I just tested r39814 with gcc 4.6.4, 4.7.4, 4.8.2 and 4.9.0 and I
didn't get any issues at all running test apps.
The static variable isn't allocated space anywhere so applications linking
to the CS library fail to link.
I didn't see a good place to define it so I did the easy thing and used a
constant.
@@ -415,7 +415,6 @@
int numObjects; // current storage used
int maxObjects; // current storage capacity
int estimateObjects; // estimated number of objects in whole tree
- static int const objectGrowth = 80; // storage growth minimum
// Minimum amount of objects in this tree before we consider
splitting.
int minSplitObjects;
Ralph Campbell
2013-10-03 17:10:09 UTC
Permalink
I did a fresh clone of CS and compiled with the original static int
const and everything worked!
Then I tried ./configure --enable-debug and found that this is what
causes the compiler to generate the undefined symbol error.
I guess the gcc flags for debug must disable that particular
optimization.
Post by Matthieu Kraus
Can you please explain me again how and where the issue arose?
I just tested r39814 with gcc 4.6.4, 4.7.4, 4.8.2 and 4.9.0 and I
didn't get any issues at all running test apps.
The static variable isn't allocated space anywhere so applications linking
to the CS library fail to link.
I didn't see a good place to define it so I did the easy thing and used a
constant.
@@ -415,7 +415,6 @@
int numObjects; // current storage used
int maxObjects; // current storage capacity
int estimateObjects; // estimated number of objects in whole tree
- static int const objectGrowth = 80; // storage growth minimum
// Minimum amount of objects in this tree before we consider
splitting.
int minSplitObjects;
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
_______________________________________________
Crystal-develop mailing list
https://lists.sourceforge.net/lists/listinfo/crystal-develop
Matthieu Kraus
2013-10-03 17:13:23 UTC
Permalink
It's still somewhat weird as I also tried in debug mode and didn't get
any error (also tried 4.2 and 4.4 to be sure). Either way, if enum
works better that's really nice, I'm just trying to figure out why I
don't get errors other people get.
Post by Ralph Campbell
I did a fresh clone of CS and compiled with the original static int
const and everything worked!
Then I tried ./configure --enable-debug and found that this is what
causes the compiler to generate the undefined symbol error.
I guess the gcc flags for debug must disable that particular
optimization.
Post by Matthieu Kraus
Can you please explain me again how and where the issue arose?
I just tested r39814 with gcc 4.6.4, 4.7.4, 4.8.2 and 4.9.0 and I
didn't get any issues at all running test apps.
The static variable isn't allocated space anywhere so
applications linking
to the CS library fail to link.
I didn't see a good place to define it so I did the easy thing
and used a
constant.
@@ -415,7 +415,6 @@
int numObjects; // current storage used
int maxObjects; // current storage capacity
int estimateObjects; // estimated number of objects in whole tree
- static int const objectGrowth = 80; // storage growth minimum
// Minimum amount of objects in this tree before we consider
splitting.
int minSplitObjects;
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
_______________________________________________
Crystal-develop mailing list
https://lists.sourceforge.net/lists/listinfo/crystal-develop
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
_______________________________________________
Crystal-develop mailing list
https://lists.sourceforge.net/lists/listinfo/crystal-develop
Ralph Campbell
2013-10-03 20:11:56 UTC
Permalink
I'm using Fedora 19 x86_64, gcc version 4.8.1.
I'm not sure how to see all the flags Jam passes to gcc.
Anyone on the list know?
Post by Matthieu Kraus
It's still somewhat weird as I also tried in debug mode and didn't get
any error (also tried 4.2 and 4.4 to be sure). Either way, if enum
works better that's really nice, I'm just trying to figure out why I
don't get errors other people get.
Post by Ralph Campbell
I did a fresh clone of CS and compiled with the original static int
const and everything worked!
Then I tried ./configure --enable-debug and found that this is what
causes the compiler to generate the undefined symbol error.
I guess the gcc flags for debug must disable that particular
optimization.
Post by Matthieu Kraus
Can you please explain me again how and where the issue arose?
I just tested r39814 with gcc 4.6.4, 4.7.4, 4.8.2 and 4.9.0 and I
didn't get any issues at all running test apps.
The static variable isn't allocated space anywhere so
applications linking
to the CS library fail to link.
I didn't see a good place to define it so I did the easy thing
and used a
constant.
@@ -415,7 +415,6 @@
int numObjects; // current storage used
int maxObjects; // current storage capacity
int estimateObjects; // estimated number of objects in whole tree
- static int const objectGrowth = 80; // storage growth minimum
// Minimum amount of objects in this tree before we consider
splitting.
int minSplitObjects;
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
_______________________________________________
Crystal-develop mailing list
https://lists.sourceforge.net/lists/listinfo/crystal-develop
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
_______________________________________________
Crystal-develop mailing list
https://lists.sourceforge.net/lists/listinfo/crystal-develop
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
_______________________________________________
Crystal-develop mailing list
https://lists.sourceforge.net/lists/listinfo/crystal-develop
Matthieu Kraus
2013-10-03 20:26:21 UTC
Permalink
to show the invocation use jam -dx -qj# instead of jam -qj# - the -dx
will instruct jam to output the commands actually run instead of
printing descriptions of them (so actual invocation instead of C++ foo).

Also 4.8.1 might be a hint - maybe that got fixed in 4.8.2? .0 and .1
gcc versions tend to have some kind of issue.
Post by Ralph Campbell
I'm using Fedora 19 x86_64, gcc version 4.8.1.
I'm not sure how to see all the flags Jam passes to gcc.
Anyone on the list know?
Post by Matthieu Kraus
It's still somewhat weird as I also tried in debug mode and didn't get
any error (also tried 4.2 and 4.4 to be sure). Either way, if enum
works better that's really nice, I'm just trying to figure out why I
don't get errors other people get.
Post by Ralph Campbell
I did a fresh clone of CS and compiled with the original static int
const and everything worked!
Then I tried ./configure --enable-debug and found that this is what
causes the compiler to generate the undefined symbol error.
I guess the gcc flags for debug must disable that particular
optimization.
Post by Matthieu Kraus
Can you please explain me again how and where the issue arose?
I just tested r39814 with gcc 4.6.4, 4.7.4, 4.8.2 and 4.9.0 and I
didn't get any issues at all running test apps.
The static variable isn't allocated space anywhere so
applications linking
to the CS library fail to link.
I didn't see a good place to define it so I did the easy thing
and used a
constant.
@@ -415,7 +415,6 @@
int numObjects; // current storage used
int maxObjects; // current storage capacity
int estimateObjects; // estimated number of objects in
whole tree
Post by Ralph Campbell
Post by Matthieu Kraus
- static int const objectGrowth = 80; // storage growth minimum
// Minimum amount of objects in this tree before we consider
splitting.
int minSplitObjects;
------------------------------------------------------------------------------
Post by Ralph Campbell
Post by Matthieu Kraus
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and
register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
Post by Ralph Campbell
Post by Matthieu Kraus
_______________________________________________
Crystal-develop mailing list
https://lists.sourceforge.net/lists/listinfo/crystal-develop
------------------------------------------------------------------------------
Post by Ralph Campbell
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get
the most from
Post by Ralph Campbell
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
Post by Ralph Campbell
_______________________________________________
Crystal-develop mailing list
https://lists.sourceforge.net/lists/listinfo/crystal-develop
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
_______________________________________________
Crystal-develop mailing list
https://lists.sourceforge.net/lists/listinfo/crystal-develop
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
_______________________________________________
Crystal-develop mailing list
https://lists.sourceforge.net/lists/listinfo/crystal-develop
Loading...