From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 41010 invoked by alias); 17 Aug 2015 16:00:51 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 40990 invoked by uid 48); 17 Aug 2015 16:00:47 -0000 From: "jeff.science at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/67251] New: gfortran does not faithfully preprocess the way cpp does Date: Mon, 17 Aug 2015 16:00:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 5.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: blocker X-Bugzilla-Who: jeff.science at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-08/txt/msg01138.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67251 Bug ID: 67251 Summary: gfortran does not faithfully preprocess the way cpp does Product: gcc Version: 5.2.0 Status: UNCONFIRMED Severity: blocker Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: jeff.science at gmail dot com Target Milestone: --- I do not understand why "gfortran -I. -E source.F" does not give the same result as "cpp-5 -I. -E source.F". It appears that gfortran does not properly preprocessor "#", "##" and "\". This breaks NWChem and there is no obvious workaround. > cat header.fh ! comment integer foo external foo #define DECL(a) \ integer err_##a; \ integer l_##a,k_##a; #define ALLO(a,s) \ err_##a=foo(s,#a,l_##a,k_##a); \ if (.not.err_##a) call bar("PUSH"#a,#s); > cat source.F C C OLD SCHOOL COMMENTS C subroutine xyz(stuff) implicit none #include "header.fh" integer stuff DECL(handle) ALLO(handle,100) print*,stuff return end > gfortran -I. -E source.F # 1 "source.F" # 1 "" # 1 "" # 1 "source.F" C C OLD SCHOOL COMMENTS C subroutine xyz(stuff) implicit none # 1 "header.fh" 1 ! comment integer foo external foo # 7 "source.F" 2 integer stuff integer err_##handle; integer l_##handle,k_##handle; err_##handle=foo(100,#handle,l_##handle,k_##handle); if (.not.err_##handle) call bar("PUSH"#handle,#100); print*,stuff return end > cpp-5 -I. -E source.F # 1 "source.F" # 1 "" # 1 "" # 1 "source.F" C C OLD SCHOOL COMMENTS C subroutine xyz(stuff) implicit none # 1 "header.fh" 1 ! comment integer foo external foo # 7 "source.F" 2 integer stuff integer err_handle; integer l_handle,k_handle; err_handle=foo(100,"handle",l_handle,k_handle); if (.not.err_handle) call bar("PUSH""handle","100"); print*,stuff return end > gfortran-5 -v Using built-in specs. COLLECT_GCC=gfortran-5 COLLECT_LTO_WRAPPER=/usr/local/Cellar/gcc/5.2.0/libexec/gcc/x86_64-apple-darwin14.4.0/5.2.0/lto-wrapper Target: x86_64-apple-darwin14.4.0 Configured with: ../configure --build=x86_64-apple-darwin14.4.0 --prefix=/usr/local/Cellar/gcc/5.2.0 --libdir=/usr/local/Cellar/gcc/5.2.0/lib/gcc/5 --enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-5 --with-gmp=/usr/local/opt/gmp --with-mpfr=/usr/local/opt/mpfr --with-mpc=/usr/local/opt/libmpc --with-isl=/usr/local/opt/isl --with-system-zlib --enable-libstdcxx-time=yes --enable-stage1-checking --enable-checking=release --enable-lto --with-build-config=bootstrap-debug --disable-werror --with-pkgversion='Homebrew gcc 5.2.0 --without-multilib' --with-bugurl=https://github.com/Homebrew/homebrew/issues --enable-plugin --disable-nls --disable-multilib Thread model: posix gcc version 5.2.0 (Homebrew gcc 5.2.0 --without-multilib)