__GXX_EXPERIMENTAL_CXX0X__

2010-10-21 Thread Neal Becker
I need a preprocessor macro to detect c++0x support.  For now, that is
 __GXX_EXPERIMENTAL_CXX0X__

but what happens once -std=c++0x is the default?  Will this macro still
be defined?  

Don't we need a

__GXX_CXX0X__ ?



c++ variable-length array?

2006-07-21 Thread Neal Becker
Using gcc-4.1.1.  Info says variable-length array is supported in c++ mode,
but doesn't seem to work:

#include 
#include 

template
void F (in_t const& in, int size, int x[size]) {}

void G (std::vector const& in, int size, int x[size]) {}

int main () {
  std::vector i (10);
  int x (10);
  F (i, boost::size (i), x);
  G (i, boost::size (i), x);
}
g++ -c Test.cc -I /usr/local/src/boost.cvs
Test.cc:5: error: ‘size’ was not declared in this scope
Test.cc:7: error: ‘size’ was not declared in this scope
Test.cc: In function ‘int main()’:
Test.cc:12: error: no matching function for call to ‘F(std::vector >&, size_t, int&)’
Test.cc:7: error: too many arguments to function ‘void G(const
std::vector >&, int)’
Test.cc:13: error: at this point in file




std::isfinite broken?

2008-07-28 Thread Neal Becker
gcc-4.3.0-8.x86_64

I have test code that does passes std::isfinite (x), yet if I print the
values to std::cout the value printed is 'inf'.  Is std::isfinite (x)
broken?



Re: std::isfinite broken?

2008-07-28 Thread Neal Becker
Paolo Carlini wrote:

> Neal Becker wrote:
>> gcc-4.3.0-8.x86_64
>>
>> I have test code that does passes std::isfinite (x), yet if I print the
>> values to std::cout the value printed is 'inf'.  Is std::isfinite (x)
>> broken?
>>   
> Whatever bug it may have - it can, of course - std::isfinite returns an
> *int*, therefore your statement seems at the very least rather weird. A
> self-contained testcase is badly needed.
> 
> Paolo.

I found that compiling without -ffast-math would allow std::isfinite to
work.  Sorry if the statement was confusing.  The code looks something
like:

[calculate x]
if (not isfinite (x))
  throw std::runtime_error ("blah")



Re: std::isfinite broken?

2008-07-28 Thread Neal Becker
Paolo Carlini wrote:

> ... ah, ok, now I see what you meant, you meant that x is *not* finite,
> still, std::isfinite(x) != 0. Still, testcase badly needed...
> 
> Paolo.
#include 
#include 

int main () {
  double x = log (0);
  if (not std::isfinite (x)) {
throw std::runtime_error ("not finite");
  }
}

Compiled with -O3 -ffast-math will not throw.



Re: std::isfinite broken?

2008-07-31 Thread Neal Becker
Paolo Carlini wrote:

> Hi ho, ho!! ;)
>> It worked with me.
>>   
> Try a recent gcc (eg, 4.3.x) and you will get the same, actually
> expected, result of the original poster.
> 
> Paolo.

I believe this is a bug.  I agree that -ffast-math will not always comply 100% 
with IEEE, as advertised.  But, if I explicity ask isfinite(), I expect it to 
work.  If it is really intended not to work, then at least documentation should 
state that.



missing optimization - don't compute return value not used?

2007-09-26 Thread Neal Becker
gcc version 4.1.2 20070502 (Red Hat 4.1.2-12)
I noticed the following code

=== version 1:
template
inline a_t append (a_t & a, b_t const& b) {
  a.insert (a.end(), b.begin(), b.end());
  return a;
}

=== version 2:
template
inline void append (a_t & a, b_t const& b) {
  a.insert (a.end(), b.begin(), b.end());
}

When instantiated for a_t, b_t std::list.  When called by code that _did
not use the return value_, I had assumed that since the returned value is
not used, the 2 versions would be equivalent.  Instead, (compiling
with -O3), version 2 runs very fast, but version 1 is extremely slow.  Is
it really necessary to construct the returned value even when it is seen
that it is not used?