public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/47853] New: Assignment of integer to pointer compiles, and a.out segfaults
@ 2011-02-22 23:02 thisrod at gmail dot com
2011-02-22 23:13 ` [Bug fortran/47853] " pinskia at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: thisrod at gmail dot com @ 2011-02-22 23:02 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47853
Summary: Assignment of integer to pointer compiles, and a.out
segfaults
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: thisrod@gmail.com
Created attachment 23438
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=23438
Source code to trigger the error
Shell trace:
% gfortran -v test.f08
Driving: gfortran -mmacosx-version-min=10.6.6 -v test.f08 -lgfortran
-shared-libgcc
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/local/gfortran/libexec/gcc/x86_64-apple-darwin10.3.0/4.5.1/lto-wrapper
Target: x86_64-apple-darwin10.3.0
Configured with: ../gcc-4_5-branch/configure --prefix=/usr/local/gfortran
--enable-languages=c,c++,fortran
--with-gmp=/Users/fx/devel/gcc/ibin45/../irun45 --enable-bootstrap
--with-included-gettext --with-arch=nocona --with-tune=generic
Thread model: posix
gcc version 4.5.1 20100506 (prerelease) (GCC)
COLLECT_GCC_OPTIONS='-mmacosx-version-min=10.6.6' '-v' '-shared-libgcc'
'-mtune=generic' '-march=nocona'
/usr/local/gfortran/libexec/gcc/x86_64-apple-darwin10.3.0/4.5.1/f951 test.f08
-fPIC -quiet -dumpbase test.f08 -mmacosx-version-min=10.6.6 -mtune=generic
-march=nocona -auxbase test -version -fintrinsic-modules-path
/usr/local/gfortran/lib/gcc/x86_64-apple-darwin10.3.0/4.5.1/finclude -o
/var/folders/9P/9PFGWXR+FHWaXgjuUM4v5U+++TU/-Tmp-//ccQWPLn5.s
GNU Fortran (GCC) version 4.5.1 20100506 (prerelease)
(x86_64-apple-darwin10.3.0)
compiled by GNU C version 4.5.1 20100506 (prerelease), GMP version 4.3.1,
MPFR version 2.4.2-p2, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU Fortran (GCC) version 4.5.1 20100506 (prerelease)
(x86_64-apple-darwin10.3.0)
compiled by GNU C version 4.5.1 20100506 (prerelease), GMP version 4.3.1,
MPFR version 2.4.2-p2, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
COLLECT_GCC_OPTIONS='-mmacosx-version-min=10.6.6' '-v' '-shared-libgcc'
'-mtune=generic' '-march=nocona'
as -arch x86_64 -force_cpusubtype_ALL -o
/var/folders/9P/9PFGWXR+FHWaXgjuUM4v5U+++TU/-Tmp-//cca9YzEf.o
/var/folders/9P/9PFGWXR+FHWaXgjuUM4v5U+++TU/-Tmp-//ccQWPLn5.s
COMPILER_PATH=/usr/local/gfortran/libexec/gcc/x86_64-apple-darwin10.3.0/4.5.1/:/usr/local/gfortran/libexec/gcc/x86_64-apple-darwin10.3.0/4.5.1/:/usr/local/gfortran/libexec/gcc/x86_64-apple-darwin10.3.0/:/usr/local/gfortran/lib/gcc/x86_64-apple-darwin10.3.0/4.5.1/:/usr/local/gfortran/lib/gcc/x86_64-apple-darwin10.3.0/
LIBRARY_PATH=/usr/local/gfortran/lib/gcc/x86_64-apple-darwin10.3.0/4.5.1/:/usr/local/gfortran/lib/gcc/x86_64-apple-darwin10.3.0/4.5.1/../../../:/usr/lib/
COLLECT_GCC_OPTIONS='-mmacosx-version-min=10.6.6' '-v' '-shared-libgcc'
'-mtune=generic' '-march=nocona'
/usr/local/gfortran/libexec/gcc/x86_64-apple-darwin10.3.0/4.5.1/collect2
-dynamic -arch x86_64 -macosx_version_min 10.6.6 -weak_reference_mismatches
non-weak -o a.out -lcrt1.10.5.o
-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin10.3.0/4.5.1
-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin10.3.0/4.5.1/../../..
/var/folders/9P/9PFGWXR+FHWaXgjuUM4v5U+++TU/-Tmp-//cca9YzEf.o -lgfortran
-lgcc_s.10.5 -lgcc_ext.10.5 -lgcc -no_compact_unwind -lSystem
COLLECT_GCC_OPTIONS='-mmacosx-version-min=10.6.6' '-v' '-shared-libgcc'
'-mtune=generic' '-march=nocona'
% ./a.out
21766: signal: sys: segmentation violation
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug fortran/47853] Assignment of integer to pointer compiles, and a.out segfaults
2011-02-22 23:02 [Bug fortran/47853] New: Assignment of integer to pointer compiles, and a.out segfaults thisrod at gmail dot com
@ 2011-02-22 23:13 ` pinskia at gcc dot gnu.org
2011-02-22 23:52 ` anlauf at gmx dot de
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2011-02-22 23:13 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47853
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> 2011-02-22 22:57:15 UTC ---
Basically you are accessing p before pointing it to anything.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug fortran/47853] Assignment of integer to pointer compiles, and a.out segfaults
2011-02-22 23:02 [Bug fortran/47853] New: Assignment of integer to pointer compiles, and a.out segfaults thisrod at gmail dot com
2011-02-22 23:13 ` [Bug fortran/47853] " pinskia at gcc dot gnu.org
@ 2011-02-22 23:52 ` anlauf at gmx dot de
2011-02-23 0:26 ` kargl at gcc dot gnu.org
2011-02-23 0:27 ` rodneyp at physics dot uq.edu.au
3 siblings, 0 replies; 5+ messages in thread
From: anlauf at gmx dot de @ 2011-02-22 23:52 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47853
Harald Anlauf <anlauf at gmx dot de> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |anlauf at gmx dot de
--- Comment #2 from Harald Anlauf <anlauf at gmx dot de> 2011-02-22 23:01:49 UTC ---
You need to allocate p before use to get a valid program.
Like:
integer, target :: a
integer, pointer :: p => NULL ()
allocate (p)
p = a ! should be =>
p = 1
end
Regarding the assignment "p = a",
please read an introduction to Fortran.
It is valid code when p is associated.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug fortran/47853] Assignment of integer to pointer compiles, and a.out segfaults
2011-02-22 23:02 [Bug fortran/47853] New: Assignment of integer to pointer compiles, and a.out segfaults thisrod at gmail dot com
2011-02-22 23:13 ` [Bug fortran/47853] " pinskia at gcc dot gnu.org
2011-02-22 23:52 ` anlauf at gmx dot de
@ 2011-02-23 0:26 ` kargl at gcc dot gnu.org
2011-02-23 0:27 ` rodneyp at physics dot uq.edu.au
3 siblings, 0 replies; 5+ messages in thread
From: kargl at gcc dot gnu.org @ 2011-02-23 0:26 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47853
kargl at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
CC| |kargl at gcc dot gnu.org
Resolution| |INVALID
--- Comment #3 from kargl at gcc dot gnu.org 2011-02-22 23:13:22 UTC ---
This is a programming mistake on the programmer. A fortran
compiler is not required to diagnose such errors. Try compiling
your code with -Wall. It shows a warning (well actually
two warnings because the program contains a tab character
where a space is expected), which should give enough information
to be concerned.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug fortran/47853] Assignment of integer to pointer compiles, and a.out segfaults
2011-02-22 23:02 [Bug fortran/47853] New: Assignment of integer to pointer compiles, and a.out segfaults thisrod at gmail dot com
` (2 preceding siblings ...)
2011-02-23 0:26 ` kargl at gcc dot gnu.org
@ 2011-02-23 0:27 ` rodneyp at physics dot uq.edu.au
3 siblings, 0 replies; 5+ messages in thread
From: rodneyp at physics dot uq.edu.au @ 2011-02-23 0:27 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47853
--- Comment #4 from rodneyp at physics dot uq.edu.au 2011-02-22 23:52:01 UTC ---
Sorry - you're right. In the original code, p and a were arrays. The
assignment p = a was still legal, but less obviously.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-02-22 23:52 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-22 23:02 [Bug fortran/47853] New: Assignment of integer to pointer compiles, and a.out segfaults thisrod at gmail dot com
2011-02-22 23:13 ` [Bug fortran/47853] " pinskia at gcc dot gnu.org
2011-02-22 23:52 ` anlauf at gmx dot de
2011-02-23 0:26 ` kargl at gcc dot gnu.org
2011-02-23 0:27 ` rodneyp at physics dot uq.edu.au
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).