public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Glenn H Sembroski <sembrosk@physics.purdue.edu>
To: gcc-help@gcc.gnu.org
Subject: Correction: Seg fault when calling Fortran from C++
Date: Wed, 31 Mar 2010 21:07:00 -0000	[thread overview]
Message-ID: <4BB360DE.30102@physics.purdue.edu> (raw)

Opps, I left a BIND(C) in my fortran code snippet that shouldn't be 
there (I was trying this and that unsuccessfully to fix the problem. The 
corrected problem description follows:
*****************************************************************************************

Hi all,
 I am having a problem where I get a segfault when my C++ main program 
calls a f77 entry point. I am using GCC4.1.2. The C++ is compiled with 
g++,  the fortran with gfortran. I use the -ffixed-line-length-none 
-fno-automatic -fno-underscoring -fbounds-check   options with 
gfortran.   The code snippits look like:

C++:
 .
 .
 //Initalize the seed:
 int k1=0;
 int k2=0;
 int lux=3;
 cout<<primeSeed<<endl;
 rluxgo(&lux,&primeSeed,&k1,&k2);
 .
 .



Fortran (its really very old legacy code) :
   .
   .
C
C                    Entry to initialize from one or three integers
     ENTRY RLUXGO(LUX,INS,K1,K2)

        IF (LUX .LT. 0) THEN
           LUXLEV = LXDFLT
        ELSE IF (LUX .LE. MAXLEV) THEN
           LUXLEV = LUX
        ELSE IF (LUX .LT. 24 .OR. LUX .GT. 2000) THEN
   .
   .


I have stepped through this with gdb and the segfault occurs when I step 
into the rluxgo call .
These files compiled and built with no problems.  I have also compiled 
and built these same files using the Intel fortran compiler. That 
program ran with no problems.
Do I need a later version of GCC? Is there something else I need to do?
Thanks,

Glenn Sembroski
Physics Dept. , Purdue Univ.
sembrosk@purdue.edu


                 reply	other threads:[~2010-03-31 14:49 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4BB360DE.30102@physics.purdue.edu \
    --to=sembrosk@physics.purdue.edu \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).