Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8246977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T22:41:17+00:00 2026-06-07T22:41:17+00:00

I work in an environment where we have a custom preprocessor for our fortran

  • 0

I work in an environment where we have a custom preprocessor for our fortran code. I use the pre-processor to toggle logical parameters as a sort of poor man’s function pointers. I realized today that I had a situation similar to this:

  program main
  logical,parameter :: untrue=.false.
  if(untrue)then
    call func1()
  else
    call func2()
  endif
  end

  subroutine func2()
  print*,"Hello, World!"
  end

In other words, func1 is not anywhere defined, but, this compiles with gfortran (version 4.4 and 4.6) because presumably the compiler optimizes that call away. I don’t have other compilers to check against at the moment, does this code compile elsewhere? Could/Should this be considered a compiler bug?

Part of the reason I toggle logical switches (instead of including/not including code) is so that the compiler can still check the interface/syntax (if capable) inside that block of code (and issue appropriate warnings for things that aren’t simple function calls). Does this imply those tests aren’t being performed or just that the function isn’t required by the linker so it all goes through Ok?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T22:41:18+00:00Added an answer on June 7, 2026 at 10:41 pm

    It is not a compiler bug. The absence of a referenced external subprogram is not something that the standard requires a Fortran processor to diagnose. Other processors may or may not complain. Things like optimisation settings may affect the outcome – Intel Fortran 12.1.5 complains with optimisation off and does not complain with optimisation on.

    For your example code, where func2 is an external subprogram, Fortran’s separate compilation model for program units means that procedure interface checking is not required. With many processors it is not likely to happen (practically func2 could perhaps be in a separate file that is compiled long after the main program, perhaps on a different machine, perhaps in a situation where the source for the main program is no longer available). If you want guaranteed procedure interface checking then you need to ensure the procedures have an explicit interface, say by putting them in a module. The procedure pointer language feature, introduced in the Fortran 2003 standard and supported by gfortran 4.6 at least, may also help.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In the software development environment where I work we have a group of developers
I have routes like: /, /login, /register, etc that work fine in dev environment.
Our company does work environment surveys, and these surveys are filled in online. All
I have a custom environment, demo, and no matter what I've tried, Rails still
I have a custom table-environment defined with \newenvironment. I have a caption in this
I work in a dev environment where we heavily use MSBuild - I find
I have an environment where multiple sites hosted on the same server will use
In your enterprise work environment, how are engineers held accountable for performing code inspections
I'm trying to create a custom attribute that will work in a sort-of AOP
Where I currently work we use a lot of hand made custom web controls

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.