Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PROG-material-public
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Walter, Wolfgang
PROG-material-public
Commits
0dcb0a46
Commit
0dcb0a46
authored
7 years ago
by
Vogt, Georg
Browse files
Options
Downloads
Patches
Plain Diff
Add compiler option
Compile with -g, so that valgrind can show line numbers
parent
77b90db4
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
einfuehrungen/einfuehrung_pointer.txt
+8
-8
8 additions, 8 deletions
einfuehrungen/einfuehrung_pointer.txt
with
8 additions
and
8 deletions
einfuehrungen/einfuehrung_pointer.txt
+
8
−
8
View file @
0dcb0a46
...
...
@@ -4,13 +4,13 @@ Pointer: Referenz auf ein Objekt (von best. Objekttyp). In FTN nur Attribut fuer
Vorteile: - Pointer koennen die komplexitaet des Codes stark reduzieren
- Pointer koennen Speicher im Heap dynamisch zur Laufzeit allokieren (aehnlich zu ALLOCATE) und
- der Heap ist betraechtlich groesser als der Stack (gilt nicht fuer Variablen mit TARGET-Attribut)
- Das verwenden von z.B. Listen ist von Vorteil, wenn Daten oft in die Mitte der Liste eingefuegt werden muessen
- Das verwenden von z.B. Listen ist von Vorteil, wenn Daten oft in die Mitte der Liste eingefuegt werden muessen
(Arrays hier eher unpraktisch)
- Pointer sind noetig, um kompliziertere Datenstrukturen (z.B. trees) ordentlich zu implementieren
In FTN werden Pointer ausser bei der "=>" Zuweisung automatisch dereferenziert.
Syntax:
Syntax:
PROGRAM testprog
...
...
@@ -44,7 +44,7 @@ Pointer Zuweisungen: "=>"
INTEGER, TARGET :: n, m
n = 1
m = 4
m = 4
ptr => n !! ptr zeigt auf n
q => ptr !! q zeigt auf n
...
...
@@ -59,12 +59,12 @@ Gefahren beim Umgang mit Pointern:
ptr => q
DEALLOCATE(q) !! ptr nun undefiniert
- memory leaks : nichterreichbare Objekte im Heap (z.B. wenn man DEALLOCATE vergisst)
- ASSOCIATED abfrage auf einen undef. Pointer
- ASSOCIATED abfrage auf einen undef. Pointer
Anzeige von
- Zugriff auf dangling pointer (error) und
- memory leaks (leak summary - definitely lost)
Anzeige von
- Zugriff auf dangling pointer (error) und
- memory leaks (leak summary - definitely lost)
nach Ausführung des Programms:
f95 testprog.f95 -o testprog
f95 testprog.f95 -o testprog
-g
valgrind ./testprog
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment