* [LTP] Question about strncpy_2-1
@ 2018-12-11 9:30 Xiao Yang
2018-12-11 9:59 ` Xiao Yang
2018-12-11 12:39 ` Cyril Hrubis
0 siblings, 2 replies; 9+ messages in thread
From: Xiao Yang @ 2018-12-11 9:30 UTC (permalink / raw)
To: ltp
Hi all,
With old gcc version(e.g. gcc-4.4), compiling strncpy_2-1 gets the following error:
----------------------------------------------------------------------------------
../../../conformance/interfaces/strncpy/1-1.c: In function ‘main’:
../../../conformance/interfaces/strncpy/1-1.c:64: error: #pragma GCC diagnostic not allowed inside functions
../../../conformance/interfaces/strncpy/1-1.c:65: error: #pragma GCC diagnostic not allowed inside functions
../../../conformance/interfaces/strncpy/1-1.c:67: error: #pragma GCC diagnostic not allowed inside functions
conformance/interfaces/strncpy/1-1 compile FAILED; SKIPPING
----------------------------------------------------------------------------------
It seems that push/pop is supported and pragma diagnostic is allowed inside functions
since commit 0955be6 in GCC.
It is clear for me to know tha fact that current gcc version doesn't support above pragma
diagnostic code, so anyone can tell me if we should keep the error?
Best Regards,
Xiao Yang
^ permalink raw reply [flat|nested] 9+ messages in thread
* [LTP] Question about strncpy_2-1
2018-12-11 9:30 [LTP] Question about strncpy_2-1 Xiao Yang
@ 2018-12-11 9:59 ` Xiao Yang
2018-12-11 12:37 ` Cyril Hrubis
2018-12-11 12:39 ` Cyril Hrubis
1 sibling, 1 reply; 9+ messages in thread
From: Xiao Yang @ 2018-12-11 9:59 UTC (permalink / raw)
To: ltp
On 2018/12/11 17:30, Xiao Yang wrote:
> Hi all,
>
> With old gcc version(e.g. gcc-4.4), compiling strncpy_2-1 gets the following error:
> ----------------------------------------------------------------------------------
> ../../../conformance/interfaces/strncpy/1-1.c: In function ‘main’:
> ../../../conformance/interfaces/strncpy/1-1.c:64: error: #pragma GCC diagnostic not allowed inside functions
> ../../../conformance/interfaces/strncpy/1-1.c:65: error: #pragma GCC diagnostic not allowed inside functions
> ../../../conformance/interfaces/strncpy/1-1.c:67: error: #pragma GCC diagnostic not allowed inside functions
> conformance/interfaces/strncpy/1-1 compile FAILED; SKIPPING
> ----------------------------------------------------------------------------------
>
> It seems that push/pop is supported and pragma diagnostic is allowed inside functions
> since commit 0955be6 in GCC.
>
> It is clear for me to know tha fact that current gcc version doesn't support above pragma
> diagnostic code, so anyone can tell me if we should keep the error?
Hi all,
In addition, this compiler error doesn't break the whole openposix compilation.
Best Regards,
Xiao Yang
> Best Regards,
> Xiao Yang
>
>
>
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [LTP] Question about strncpy_2-1
2018-12-11 9:30 [LTP] Question about strncpy_2-1 Xiao Yang
2018-12-11 9:59 ` Xiao Yang
@ 2018-12-11 12:39 ` Cyril Hrubis
2018-12-12 10:40 ` [LTP] [PATCH] openposix/strncpy1-1: Fix compiler errors/warnings Xiao Yang
1 sibling, 1 reply; 9+ messages in thread
From: Cyril Hrubis @ 2018-12-11 12:39 UTC (permalink / raw)
To: ltp
Hi!
> With old gcc version(e.g. gcc-4.4), compiling strncpy_2-1 gets the following error:
> ----------------------------------------------------------------------------------
> ../../../conformance/interfaces/strncpy/1-1.c: In function ???main???:
> ../../../conformance/interfaces/strncpy/1-1.c:64: error: #pragma GCC diagnostic not allowed inside functions
> ../../../conformance/interfaces/strncpy/1-1.c:65: error: #pragma GCC diagnostic not allowed inside functions
> ../../../conformance/interfaces/strncpy/1-1.c:67: error: #pragma GCC diagnostic not allowed inside functions
> conformance/interfaces/strncpy/1-1 compile FAILED; SKIPPING
> ----------------------------------------------------------------------------------
>
> It seems that push/pop is supported and pragma diagnostic is allowed inside functions
> since commit 0955be6 in GCC.
Looks like an attempt to silence warnings, but a lousy one that would
break on anything but new enough gcc, let's get rid of that.
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 9+ messages in thread
* [LTP] [PATCH] openposix/strncpy1-1: Fix compiler errors/warnings
2018-12-11 12:39 ` Cyril Hrubis
@ 2018-12-12 10:40 ` Xiao Yang
2018-12-14 8:33 ` Cyril Hrubis
0 siblings, 1 reply; 9+ messages in thread
From: Xiao Yang @ 2018-12-12 10:40 UTC (permalink / raw)
To: ltp
pragma diagnostic can support push/pop and be allowed inside functions
by commit 0955be65 on gcc-4.6, and it can support -Wstringop-truncation
by commit d8aad78 on gcc-8.1. We try to avoid some compiler errors or
warnings by just using pragma diagnostic for test on newer gcc(i.e. >= gcc-8.1)
because compiling and running test don't get any failure after removing
pragma diagnostic on older gcc.
For example:
1)compiling test gets the following error on gcc-4.4:
------------------------------------------------------
error: #pragma GCC diagnostic not allowed inside functions
------------------------------------------------------
2)compiling test gets the following warning on gcc-4.8:
-----------------------------------------------------
warning: unknown option after ‘#pragma GCC diagnostic’ kind [-Wpragmas]
------------------------------------------------------
Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
---
.../conformance/interfaces/strncpy/1-1.c | 10 +++++++---
testcases/open_posix_testsuite/include/posixtest.h | 2 ++
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/strncpy/1-1.c b/testcases/open_posix_testsuite/conformance/interfaces/strncpy/1-1.c
index 396bd60..7006b5f 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/strncpy/1-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/strncpy/1-1.c
@@ -61,10 +61,14 @@ int main(void)
sample_str_1 = random_string(i);
num_bytes = rand() % i;
- #pragma GCC diagnostic push
- #pragma GCC diagnostic ignored "-Wstringop-truncation"
+ #if GCC_VERSION >= 80100
+ # pragma GCC diagnostic push
+ # pragma GCC diagnostic ignored "-Wstringop-truncation"
+ #endif
ret_str = strncpy(sample_str_2, sample_str_1, num_bytes);
- #pragma GCC diagnostic pop
+ #if GCC_VERSION >= 80100
+ # pragma GCC diagnostic pop
+ #endif
sample_str_2[num_bytes] = '\0';
sample_str_1[num_bytes] = '\0';
diff --git a/testcases/open_posix_testsuite/include/posixtest.h b/testcases/open_posix_testsuite/include/posixtest.h
index dd1a9b2..8859804 100644
--- a/testcases/open_posix_testsuite/include/posixtest.h
+++ b/testcases/open_posix_testsuite/include/posixtest.h
@@ -47,3 +47,5 @@
#define LTP_ATTRIBUTE_NORETURN __attribute__((noreturn))
#define LTP_ATTRIBUTE_UNUSED __attribute__((unused))
#define LTP_ATTRIBUTE_UNUSED_RESULT __attribute__((warn_unused_result))
+
+#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
--
1.7.1
^ permalink raw reply related [flat|nested] 9+ messages in thread* [LTP] [PATCH] openposix/strncpy1-1: Fix compiler errors/warnings
2018-12-12 10:40 ` [LTP] [PATCH] openposix/strncpy1-1: Fix compiler errors/warnings Xiao Yang
@ 2018-12-14 8:33 ` Cyril Hrubis
2018-12-14 8:17 ` [LTP] [PATCH v2] " Xiao Yang
2018-12-14 8:40 ` [LTP] [PATCH] " Xiao Yang
0 siblings, 2 replies; 9+ messages in thread
From: Cyril Hrubis @ 2018-12-14 8:33 UTC (permalink / raw)
To: ltp
Hi!
> Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
> ---
> .../conformance/interfaces/strncpy/1-1.c | 10 +++++++---
> testcases/open_posix_testsuite/include/posixtest.h | 2 ++
> 2 files changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/testcases/open_posix_testsuite/conformance/interfaces/strncpy/1-1.c b/testcases/open_posix_testsuite/conformance/interfaces/strncpy/1-1.c
> index 396bd60..7006b5f 100644
> --- a/testcases/open_posix_testsuite/conformance/interfaces/strncpy/1-1.c
> +++ b/testcases/open_posix_testsuite/conformance/interfaces/strncpy/1-1.c
> @@ -61,10 +61,14 @@ int main(void)
> sample_str_1 = random_string(i);
> num_bytes = rand() % i;
>
> - #pragma GCC diagnostic push
> - #pragma GCC diagnostic ignored "-Wstringop-truncation"
> + #if GCC_VERSION >= 80100
> + # pragma GCC diagnostic push
> + # pragma GCC diagnostic ignored "-Wstringop-truncation"
> + #endif
> ret_str = strncpy(sample_str_2, sample_str_1, num_bytes);
> - #pragma GCC diagnostic pop
> + #if GCC_VERSION >= 80100
> + # pragma GCC diagnostic pop
> + #endif
That looks even more silly than the original. I do not think that it's
reasonable to mess up the code that bad only to surpress a single
warning.
So what abour removing the pragmas entirely?
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 9+ messages in thread
* [LTP] [PATCH v2] openposix/strncpy1-1: Fix compiler errors/warnings
2018-12-14 8:33 ` Cyril Hrubis
@ 2018-12-14 8:17 ` Xiao Yang
2018-12-14 12:47 ` Cyril Hrubis
2018-12-14 8:40 ` [LTP] [PATCH] " Xiao Yang
1 sibling, 1 reply; 9+ messages in thread
From: Xiao Yang @ 2018-12-14 8:17 UTC (permalink / raw)
To: ltp
pragma diagnostic can support push/pop and be allowed inside functions
by commit 0955be65 on gcc-4.6, and it can support -Wstringop-truncation
by commit d8aad78 on gcc-8.1. We try to avoid some compiler errors or
warnings by removing pragma diagnostic for test directly, because we
don't get any failure after removing it on old/new gcc.
For example:
1)compiling test gets the following error on gcc-4.4:
------------------------------------------------------
error: #pragma GCC diagnostic not allowed inside functions
------------------------------------------------------
2)compiling test gets the following warning on gcc-4.8:
-----------------------------------------------------
warning: unknown option after ‘#pragma GCC diagnostic’ kind [-Wpragmas]
------------------------------------------------------
Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
---
testcases/open_posix_testsuite/conformance/interfaces/strncpy/1-1.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/strncpy/1-1.c b/testcases/open_posix_testsuite/conformance/interfaces/strncpy/1-1.c
index 396bd60..b67d09d 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/strncpy/1-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/strncpy/1-1.c
@@ -61,10 +61,7 @@ int main(void)
sample_str_1 = random_string(i);
num_bytes = rand() % i;
- #pragma GCC diagnostic push
- #pragma GCC diagnostic ignored "-Wstringop-truncation"
ret_str = strncpy(sample_str_2, sample_str_1, num_bytes);
- #pragma GCC diagnostic pop
sample_str_2[num_bytes] = '\0';
sample_str_1[num_bytes] = '\0';
--
1.8.3.1
^ permalink raw reply related [flat|nested] 9+ messages in thread* [LTP] [PATCH] openposix/strncpy1-1: Fix compiler errors/warnings
2018-12-14 8:33 ` Cyril Hrubis
2018-12-14 8:17 ` [LTP] [PATCH v2] " Xiao Yang
@ 2018-12-14 8:40 ` Xiao Yang
1 sibling, 0 replies; 9+ messages in thread
From: Xiao Yang @ 2018-12-14 8:40 UTC (permalink / raw)
To: ltp
On 2018/12/14 16:33, Cyril Hrubis wrote:
> Hi!
>> Signed-off-by: Xiao Yang<yangx.jy@cn.fujitsu.com>
>> ---
>> .../conformance/interfaces/strncpy/1-1.c | 10 +++++++---
>> testcases/open_posix_testsuite/include/posixtest.h | 2 ++
>> 2 files changed, 9 insertions(+), 3 deletions(-)
>>
>> diff --git a/testcases/open_posix_testsuite/conformance/interfaces/strncpy/1-1.c b/testcases/open_posix_testsuite/conformance/interfaces/strncpy/1-1.c
>> index 396bd60..7006b5f 100644
>> --- a/testcases/open_posix_testsuite/conformance/interfaces/strncpy/1-1.c
>> +++ b/testcases/open_posix_testsuite/conformance/interfaces/strncpy/1-1.c
>> @@ -61,10 +61,14 @@ int main(void)
>> sample_str_1 = random_string(i);
>> num_bytes = rand() % i;
>>
>> - #pragma GCC diagnostic push
>> - #pragma GCC diagnostic ignored "-Wstringop-truncation"
>> + #if GCC_VERSION>= 80100
>> + # pragma GCC diagnostic push
>> + # pragma GCC diagnostic ignored "-Wstringop-truncation"
>> + #endif
>> ret_str = strncpy(sample_str_2, sample_str_1, num_bytes);
>> - #pragma GCC diagnostic pop
>> + #if GCC_VERSION>= 80100
>> + # pragma GCC diagnostic pop
>> + #endif
> That looks even more silly than the original. I do not think that it's
> reasonable to mess up the code that bad only to surpress a single
> warning.
>
> So what abour removing the pragmas entirely?
>
Hi Cyril,
I didn't get any failure after removing the pragmas on older/newer gcc,
so i think
we can remove it directly.
Best Regards,
Xiao Yang
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2018-12-14 12:47 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-11 9:30 [LTP] Question about strncpy_2-1 Xiao Yang
2018-12-11 9:59 ` Xiao Yang
2018-12-11 12:37 ` Cyril Hrubis
2018-12-11 12:39 ` Cyril Hrubis
2018-12-12 10:40 ` [LTP] [PATCH] openposix/strncpy1-1: Fix compiler errors/warnings Xiao Yang
2018-12-14 8:33 ` Cyril Hrubis
2018-12-14 8:17 ` [LTP] [PATCH v2] " Xiao Yang
2018-12-14 12:47 ` Cyril Hrubis
2018-12-14 8:40 ` [LTP] [PATCH] " Xiao Yang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox