Re: feedback on 2.69b

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jul 24, 2020 at 9:53 AM Peter Eisentraut <peter@xxxxxxxxxxxxxx> wrote:
>
> Here is some feedback on applying the 2.69b beta on the PostgreSQL
> source tree.  Basically, everything worked fine.

This is great news.  Thank you for testing.

> One issue we would like to point out is that the new scheme of
> automatically checking for the latest version of the C and C++ standards
> (deprecating AC_PROG_CC_C99 etc.) is problematic in two ways.
>
> First, we have set C99 as the project standard.  So checking for C11 is
> (a) useless, and (b) bad because we don't want developers to
> accidentally make use of C11 features and have the compiler accept them
> silently. [...] It would be better if there were still a way to set the
> preferred level of C and C++ in an official way.

I can't promise to make that happen for 2.70 but I will definitely add
it to the list of things that would be nice to have if we can find the
time to implement them.

> Second, the additional tests for C11 and C++11 are slow.  This entirely
> eliminates all the performance improvements made elsewhere.  In
> particular, the test
>
> checking for g++ option to enable C++11 features... none needed
>
> takes on the order of 10 seconds for some developers.  And that is for
> one loop, since "none needed"; good luck if you need more than none.

I suspect that this is because the test program for C++11 includes a
bunch of large and complicated C++ standard library headers.   To
confirm that possibility, could you please ask someone who sees
"checking for g++ option to enable C++11 features ... none needed"
take 10 seconds to compile the appended test program with  `g++ -O2 -g
-c` and report how long it takes.  (It takes ~3s on my computer, which
is already too long IMHO, but if it doesn't take any longer than that
for them, something else must be wrong as well.)

Assuming that's what's wrong, I know what to do about it and we'll
make sure that does happen for 2.70.

zw
---

#include <deque>
#include <functional>
#include <memory>
#include <tuple>
#include <array>
#include <regex>
#include <iostream>

namespace cxx11test
{
  typedef std::shared_ptr<std::string> sptr;
  typedef std::weak_ptr<std::string> wptr;

  typedef std::tuple<std::string,int,double> tp;
  typedef std::array<int, 20> int_array;

  constexpr int get_val() { return 20; }

  struct testinit
  {
    int i;
    double d;
  };

  class delegate  {
  public:
    delegate(int n) : n(n) {}
    delegate(): delegate(2354) {}

    virtual int getval() { return this->n; };
  protected:
    int n;
  };

  class overridden : public delegate {
  public:
    overridden(int n): delegate(n) {}
    virtual int getval() override final { return this->n * 2; }
  };

  class nocopy {
  public:
    nocopy(int i): i(i) {}
    nocopy() = default;
    nocopy(const nocopy&) = delete;
    nocopy & operator=(const nocopy&) = delete;
  private:
    int i;
  };
}

int main(void)
{
{
  // Test auto and decltype
  std::deque<int> d;
  d.push_front(43);
  d.push_front(484);
  d.push_front(3);
  d.push_front(844);
  int total = 0;
  for (auto i = d.begin(); i != d.end(); ++i) { total += *i; }

  auto a1 = 6538;
  auto a2 = 48573953.4;
  auto a3 = "String literal";

  decltype(a2) a4 = 34895.034;
}
{
  // Test constexpr
  short sa[cxx11test::get_val()] = { 0 };
}
{
  // Test initializer lists
  cxx11test::testinit il = { 4323, 435234.23544 };
}
{
  // Test range-based for and lambda
  cxx11test::int_array array = {9, 7, 13, 15, 4, 18, 12, 10, 5, 3, 14,
19, 17, 8, 6, 20, 16, 2, 11, 1};
  for (int &x : array) { x += 23; }
  std::for_each(array.begin(), array.end(), [](int v1){ std::cout << v1; });
}
{
  using cxx11test::sptr;
  using cxx11test::wptr;

  sptr sp(new std::string("ASCII string"));
  wptr wp(sp);
  sptr sp2(wp);
}
{
  cxx11test::tp tuple("test", 54, 45.53434);
  double d = std::get<2>(tuple);
  std::string s;
  int i;
  std::tie(s,i,d) = tuple;
}
{
  static std::regex filename_regex("^_?([a-z0-9_.]+-)+[a-z0-9]+$");
  std::string testmatch("Test if this string matches");
  bool match = std::regex_search(testmatch, filename_regex);
}
{
  cxx11test::int_array array = {9, 7, 13, 15, 4, 18, 12, 10, 5, 3, 14,
19, 17, 8, 6, 20, 16, 2, 11, 1};
  cxx11test::int_array::size_type size = array.size();
}
{
  // Test constructor delegation
  cxx11test::delegate d1;
  cxx11test::delegate d2();
  cxx11test::delegate d3(45);
}
{
  // Test override and final
  cxx11test::overridden o1(55464);
}
{
  // Test nullptr
  char *c = nullptr;
}
{
  // Test template brackets
  std::vector<std::pair<int,char*>> v1;
}
{
  // Unicode literals
  char const *utf8 = u8"UTF-8 string \u2500";
  char16_t const *utf16 = u"UTF-8 string \u2500";
  char32_t const *utf32 = U"UTF-32 string \u2500";
}
}




[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux