Re: [GENERAL] C++ port of Postgres

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Piotr Stefaniak <postgres(at)piotr-stefaniak(dot)me>
Cc: Jim Nasby <Jim(dot)Nasby(at)bluetreble(dot)com>, Gavin Flower <GavinFlower(at)archidevsys(dot)co(dot)nz>, dandl <david(at)andl(dot)org>, Adam Brusselback <adambrusselback(at)gmail(dot)com>, Joy Arulraj <jarulraj(at)cs(dot)cmu(dot)edu>, kang joni <kangjoni76(at)gmail(dot)com>, Dmitry Igrishin <dmitigr(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, Peter Eisentraut <peter_e(at)gmx(dot)net>
Subject: Re: [GENERAL] C++ port of Postgres
Date: 2016-08-17 15:20:46
Message-ID: CA+TgmobcpmwEnOLCeJPxzpyUkYDg9utWmV_bMMXACxiNY0krAA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

On Tue, Aug 16, 2016 at 5:08 PM, Piotr Stefaniak
<postgres(at)piotr-stefaniak(dot)me> wrote:
> On 2016-08-16 18:33, Robert Haas wrote:
>> It wouldn't be that much work to maintain, either: we'd
>> just set up some buildfarm members that compiled using C++ and when
>> they turned red, we'd go fix it.
>
> I think that there exist subtle differences between C and C++ that
> without compile-time diagnostic could potentially lead to different
> run-time behavior. As an artificial example:
>
> $ cat ./test.c
> #include <stdio.h>
>
> int main(void) {
> FILE *f = fopen("test.bin", "w");
> if (f == NULL)
> return 1;
> fwrite("1", sizeof '1', 1, f);
> fclose(f);
> return 0;
> }
> $ clang ./test.c -o test
> $ ./test
> $ hexdump test.bin
> 0000000 0031 0000
> 0000004
> $ clang++ ./test.c -o test
> clang-3.9: warning: treating 'c' input as 'c++' when in C++ mode, this
> behavior is deprecated
> $ ./test
> $ hexdump test.bin
> 0000000 0031
> 0000001

Hmm, so sizeof() has different semantics in C vs. C++?

While that's a little alarming, I'm wondering whether this sort of
thing is likely to actually be a problem in practice. We have such a
long laundry list of coding conventions already that I am inclined to
believe we could add a few more without breaking our ability to do
development.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Andrew Gierth 2016-08-17 15:36:05 Re: [GENERAL] C++ port of Postgres
Previous Message Dmitry Igrishin 2016-08-17 15:00:51 Re: [GENERAL] C++ port of Postgres

Browse pgsql-hackers by date

  From Date Subject
Next Message Ryan Murphy 2016-08-17 15:21:03 Re: Patch: initdb: "'" for QUOTE_PATH (non-windows)
Previous Message Dmitry Igrishin 2016-08-17 15:00:51 Re: [GENERAL] C++ port of Postgres