[Mesa-dev] [PATCH] util: fix in-class initialization of static member

Vinson Lee vlee at freedesktop.org
Wed Sep 27 20:51:33 UTC 2017


On Wed, Sep 27, 2017 at 12:36 PM, Thomas Helland
<thomashelland90 at gmail.com> wrote:
> string_buffer_test.cpp:43: error: ISO C++ forbids initialization of
> member ‘str1’
> string_buffer_test.cpp:43: error: making ‘str1’ static
> string_buffer_test.cpp:43: error: invalid in-class initialization of
> static data member of non-integral type ‘const char*’
>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=103002
> ---
>  src/util/tests/string_buffer/string_buffer_test.cpp | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/src/util/tests/string_buffer/string_buffer_test.cpp b/src/util/tests/string_buffer/string_buffer_test.cpp
> index c3d43cb67b..545f607fad 100644
> --- a/src/util/tests/string_buffer/string_buffer_test.cpp
> +++ b/src/util/tests/string_buffer/string_buffer_test.cpp
> @@ -40,9 +40,9 @@ class string_buffer : public ::testing::Test {
>  public:
>
>     struct _mesa_string_buffer *buf;
> -   const char *str1 = "test1";
> -   const char *str2 = "test2";
> -   const char *str3 = "test1test2";
> +   const char *str1;
> +   const char *str2;
> +   const char *str3;
>     char str4[80];
>     char str5[40];
>
> @@ -53,6 +53,9 @@ public:
>  void
>  string_buffer::SetUp()
>  {
> +   str1 = "test1";
> +   str2 = "test2";
> +   str3 = "test1test2";
>     buf = _mesa_string_buffer_create(NULL, INITIAL_BUF_SIZE);
>  }
>
> --
> 2.14.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Tested that this patch fixes g++ 4.4 build error.

Tested-by: Vinson Lee <vlee at freedesktop.org>


More information about the mesa-dev mailing list