This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch, fortran, 4.9] Use bool type instead gfc_try


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]