This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: [Patch, fortran, 4.9] Use bool type instead gfc_try
- From: "N.M. Maclaren" <nmm1 at cam dot ac dot uk>
- To: Fortran List <fortran at gcc dot gnu dot org>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: 22 Mar 2013 09:17:17 +0000
- Subject: Re: [Patch, fortran, 4.9] Use bool type instead gfc_try
- References: <CAO9iq9F0rhbqe-LMB1d=0pNyKraPK_KVKc2Tg1j2EP8Zu+EUgA at mail dot gmail dot com> <5148A0A0 dot 8010209 at net-b dot de> <Prayer dot 1 dot 3 dot 5 dot 1303212205310 dot 2429 at hermes-1 dot csi dot cam dot ac dot uk> <Pine dot LNX dot 4 dot 64 dot 1303212333510 dot 12788 at digraph dot polyomino dot org dot uk> <Prayer dot 1 dot 3 dot 5 dot 1303220818260 dot 8781 at hermes-1 dot csi dot cam dot ac dot uk> <87wqsz6djz dot fsf at catnip dot gol dot com>
On Mar 22 2013, Miles Bader wrote:
That is another matter entirely. The code of gcc/gfortran is supposed
to be compilable with other compilers, and it is foolish to make
unnecessary assumptions by relying on undefined behaviour.
The simple facts are that C++ does NOT define bool to be compatible with
_Bool, and there are enough differences in specification and semantics
to make it likely that they are not the same in at least some compilers.
This mess has caused and still causes no end of problems for Fortran
interoperability and in standards like MPI.
Er, maybe so, but is there actually an issue in _this_ case?
Yes. There are many ways of resolving it, one of which is to state that
gfortran MUST be compiled in a second pass using gcc, after having built
gcc. Another is described below.
From original message, it sounds like these are internal compiler
interfaces, so all that matters is that they be self-consistent, and
there's no external ABI involved... So as long as all the code in
question is compiled with C++ and uses C++ bool, or is compiled with
C99 and uses _Bool, and doesn't use any functionality that isn't in
the intersection of those two types, there shouldn't be any problem,
right?
And that is precisely the point. The risk isn't in either of them,
but in any interface that passes C++ bool from the front-end to C99
_Bool in the back end. If you exclude that, there is no problem.
This is a symptom of a much wider and more serious malaise, which
I do NOT think should be discussed in this thread. I am going to
mention it only if someone wants to contact me about it by Email,
or start a new thread.
There are much more and fouller gotchas to do with C++ and C99.
complex is worse, because there are serious differences in the
alignment requirements, and I know that affects some systems quite
badly. But the real nasties are to do with <cmath> and errno and,
worst of all, the horrors of C99 Annex F.
My point here is that it is VERY important not to read the political
sound-bite that C++ is now based on C99 and assume that they are
actually compatible in all respects where they have 'equivalent'
facilities. They aren't.
Regards,
Nick Maclaren.
- References:
- [Patch, fortran, 4.9] Use bool type instead gfc_try
- Re: [Patch, fortran, 4.9] Use bool type instead gfc_try
- Re: [Patch, fortran, 4.9] Use bool type instead gfc_try
- Re: [Patch, fortran, 4.9] Use bool type instead gfc_try
- Re: [Patch, fortran, 4.9] Use bool type instead gfc_try
- Re: [Patch, fortran, 4.9] Use bool type instead gfc_try