🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #2251

Re: F90 vs C++/C, optimization question?

#2251
From: J. Kanze
Date: Thu, 19 Oct 1995 10:44
50 lines
2894 bytes
Bill Leonard (bill@amber.ssd.hcsc.com) wrote:
|> kanze@gabi-soft.fr (J. Kanze) writes:
|> > enseeg14@grenet.fr wrote:
|> > 
|> > |> > for (i = 0 ; i < n ; i++) {
|> > |> >    for (j = 0 ; j < n ; j++) {
|> > |> >       a[i][j] = b[i][j] * c[i] ;
|> > |> >    }
|> > |> > }
|> > 
|> > |> > do j = 1,m
|> > |> >   do i = 1, n
|> > |> >     a (i,j) = b(i,j) * c(i)
|> > |> >   enddo
|> > |> > enddo 
|> > 
|> > Const won't help, and the problem isn't typing, but potential aliasing.
|> > Fortran basically says that the results are undefined if aliasing is
|> > present, C/C++ doesn't.

    [...]

|> > There is a proposed extention to C which would do it, a sort of son of
|> > noalias.  I don't know any of the details, but I'm sure that a question
|> > in comp.std.c would reach people who did, or who could point you in the
|> > right direction.

|> I continue to think such extensions are a bad idea.  They basically force
|> the compiler to trust the programmer, and historically that is not a
|> reliable thing to do.  The original programmer may have been careful to
|> avoid aliasing, but what about the 50 other programmers who came later and
|> made modifications to the program?  Worse still, you may have a bug lurking
|> there for decades until you happen to compile with a compiler that takes
|> advantage of the noalias declaration *and* does it in such a way that the
|> illegal aliasing changes the behavior of the program.  Such bugs are
|> extremely difficult to track down.

I agree (although I'm not too familiar with the proposal, except for
knowing that it exists).  The real problem is that the declaration
affects the code generation in the function, but requires discipline on
the part of the callers.
-- 
James Kanze           (+33) 88 14 49 00          email: kanze@gabi-soft.fr
GABI Software, Sarl., 8 rue des Francs Bourgeois, 67000 Strasbourg, France
Conseils en informatique industrielle--
                             --Beratung in industrieller Datenverarbeitung
---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID: <4658ir$5av@gabi.gabi-soft.fr>
Path: arc1-ca.pugleaf.net!in2.uu.net!bounce-back
References: <45ld1i$m7i@cicg-communication.grenet.fr> <45o2n2$o48@gabi.gabi-soft.fr> <45tq00$dkd@hawk.hcsc.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!in2.uu.net!bounce-back
Date: 19 Oct 95 10:44:09 GMT
Approved: fjh@cs.mu.oz.au
From: kanze@gabi-soft.fr (J. Kanze)
Newsgroups: comp.std.c++
Subject: Re: F90 vs C++/C, optimization question?
X-Original-Date: 19 Oct 1995 11:16:59 +0100
Organization: GABI Software, Sarl.
Message-ID: <4658ir$5av@gabi.gabi-soft.fr>
References: <45ld1i$m7i@cicg-communication.grenet.fr> <45o2n2$o48@gabi.gabi-soft.fr> <45tq00$dkd@hawk.hcsc.com>
X-Newsreader: TIN [version 1.2 PL2]
X-Auth: PGPMoose V1.1 PGP comp.std.c++
 iQBFAgUBMIYsLuEDnX0m9pzZAQEhcwF+KJcnaeWDqkBJTpa8Gm8NWjdk2wny3alt
 cTSqDFMu5OCq1CajJXzdWJTgeMVlVzuG
 =kzdP