forked from dealii/dealii
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix dealii#15111. ParameterAcceptor now uses a set.
- Loading branch information
1 parent
70d13b7
commit c7c8b54
Showing
5 changed files
with
155 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Fixed: ParameterAcceptor::clear() had issues with 'use after free'. | ||
<br> | ||
(Luca Heltai, 2023/04/20) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
//----------------------------------------------------------- | ||
// | ||
// Copyright (C) 2023 by the deal.II authors | ||
// | ||
// This file is part of the deal.II library. | ||
// | ||
// The deal.II library is free software; you can use it, redistribute | ||
// it, and/or modify it under the terms of the GNU Lesser General | ||
// Public License as published by the Free Software Foundation; either | ||
// version 2.1 of the License, or (at your option) any later version. | ||
// The full text of the license can be found in the file LICENSE.md at | ||
// the top level directory of deal.II. | ||
// | ||
//----------------------------------------------------------- | ||
|
||
|
||
// Test that clear works as expected. | ||
|
||
#include <deal.II/base/parameter_acceptor.h> | ||
|
||
#include "../tests.h" | ||
|
||
struct Foo : public dealii::ParameterAcceptor | ||
{}; | ||
|
||
|
||
struct Bar : public dealii::ParameterAcceptor | ||
{ | ||
Bar() | ||
{ | ||
add_parameter("A parameter", a); | ||
} | ||
int a = 1; | ||
}; | ||
|
||
int | ||
main() | ||
{ | ||
initlog(); | ||
{ | ||
Foo foo; | ||
ParameterAcceptor::clear(); | ||
// <-- foo goes out of scope here | ||
} | ||
|
||
{ | ||
Bar bar; | ||
ParameterAcceptor::prm.log_parameters(deallog); | ||
ParameterAcceptor::clear(); | ||
ParameterAcceptor::prm.log_parameters(deallog); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
DEAL:parameters:Bar::A parameter: 1 |