public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/108150] New: gcc.dg/attr-aligned.c fails with incorrect max alignment
@ 2022-12-17  1:40 nightstrike at gmail dot com
  2022-12-19  8:19 ` [Bug testsuite/108150] " nightstrike at gmail dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: nightstrike at gmail dot com @ 2022-12-17  1:40 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108150

            Bug ID: 108150
           Summary: gcc.dg/attr-aligned.c fails with incorrect max
                    alignment
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nightstrike at gmail dot com
  Target Milestone: ---

On Windows targets, the max alignment is 8192.  However, this test winds up
assuming the max alignment is much larger, causing multiple failures. 
Specifically, the test is getting into:

#elif __powerpc64__ || __x86_64__
/* Is this processor- or operating-system specific?  */
#  define ALIGN_MAX_STATIC      ALIGN_MAX_HARD

and ALIGN_MAX_HARD is set to:

/* The maximum alignment GCC can handle.  */
#define ALIGN_MAX_HARD 0x10000000


If it fell through to:
#else
   /* Guaranteed to be accepted regardless of the target.  */
#  define ALIGN_MAX_STATIC      __BIGGEST_ALIGNMENT__

that would still be wrong, as __BIGGEST_ALIGNMENT__ is set to 16.


Another case that checks for Windows and sets it to 8192 should fix it.  The
check should cover all windows platforms, including cygwin and msys. 
Technically, msys defines both __MSYS__ and __CYGWIN__, so testing for
__CYGWIN__ || __MINGW32__ || __MINGW64__ would cover all bases.  Alternatively,
and potentially easier, __WINT_MAX__ is defined on all targets, so you could
just test for that.


Someone will likely want to do it perhaps in a more sophisticated way, or be
more obvious about the macros being tested if WINT_MAX is an obscure choice, or
some other reason.  However, the following change works:

diff --git a/gcc/testsuite/gcc.dg/attr-aligned.c
b/gcc/testsuite/gcc.dg/attr-aligned.c
index a2e11c96180..a56973c99b4 100644
--- a/gcc/testsuite/gcc.dg/attr-aligned.c
+++ b/gcc/testsuite/gcc.dg/attr-aligned.c
@@ -22,6 +22,9 @@
 #  define ALIGN_MAX_STATIC      2
 /* Work around a pdp11 ICE (see PR target/87821).  */
 #  define ALIGN_MAX_AUTO        (ALIGN_MAX_HARD >> 14)
+#elif __WINT_MAX__
+#  define ALIGN_MAX_STATIC      8192
+#  define ALIGN_MAX_AUTO        8192
 #elif __powerpc64__ || __x86_64__
 /* Is this processor- or operating-system specific?  */
 #  define ALIGN_MAX_STATIC      ALIGN_MAX_HARD


For reference, these are the excess errors:
gcc/testsuite/gcc.dg/attr-aligned.c:65:1: error: requested alignment
'268435456' exceeds object file maximum 8192
gcc/testsuite/gcc.dg/attr-aligned.c:66:1: error: requested alignment
'268435456' exceeds object file maximum 8192
gcc/testsuite/gcc.dg/attr-aligned.c:67:1: error: requested alignment
'268435456' exceeds object file maximum 8192
gcc/testsuite/gcc.dg/attr-aligned.c:68:1: error: requested alignment
'268435456' exceeds object file maximum 8192
gcc/testsuite/gcc.dg/attr-aligned.c:70:1: error: static assertion failed
gcc/testsuite/gcc.dg/attr-aligned.c:71:1: error: static assertion failed
gcc/testsuite/gcc.dg/attr-aligned.c:72:1: error: static assertion failed
gcc/testsuite/gcc.dg/attr-aligned.c:73:1: error: static assertion failed
gcc/testsuite/gcc.dg/attr-aligned.c:61:22: error: alignment of 't_max' is
greater than maximum object file alignment 8192
gcc/testsuite/gcc.dg/attr-aligned.c:78:47: error: alignment of 'alignas_sc_max'
is greater than maximum object file alignment 8192
gcc/testsuite/gcc.dg/attr-aligned.c:79:40: error: alignment of 'alignas_c_max'
is greater than maximum object file alignment 8192
gcc/testsuite/gcc.dg/attr-aligned.c:80:34: error: alignment of 'alignas_v_max'
is greater than maximum object file alignment 8192
gcc/testsuite/gcc.dg/attr-aligned.c:99:31: error: alignment of 'aligned_st_max'
is greater than maximum object file alignment 8192

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug testsuite/108150] gcc.dg/attr-aligned.c fails with incorrect max alignment
  2022-12-17  1:40 [Bug c/108150] New: gcc.dg/attr-aligned.c fails with incorrect max alignment nightstrike at gmail dot com
@ 2022-12-19  8:19 ` nightstrike at gmail dot com
  2022-12-27 22:43 ` nightstrike at gmail dot com
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: nightstrike at gmail dot com @ 2022-12-19  8:19 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108150

--- Comment #1 from nightstrike <nightstrike at gmail dot com> ---
Ok, that was dumb.. WINT_MAX is wide int max... hah.  So maybe test for
__CYGWIN__ || __WIN32__

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug testsuite/108150] gcc.dg/attr-aligned.c fails with incorrect max alignment
  2022-12-17  1:40 [Bug c/108150] New: gcc.dg/attr-aligned.c fails with incorrect max alignment nightstrike at gmail dot com
  2022-12-19  8:19 ` [Bug testsuite/108150] " nightstrike at gmail dot com
@ 2022-12-27 22:43 ` nightstrike at gmail dot com
  2023-01-08  1:33 ` 10walls at gmail dot com
  2023-01-28 16:32 ` cvs-commit at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: nightstrike at gmail dot com @ 2022-12-27 22:43 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108150

nightstrike <nightstrike at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |10walls at gmail dot com

--- Comment #2 from nightstrike <nightstrike at gmail dot com> ---
It occurs to me, if GCC already internally knows the max alignment (since it's
outputting it in the warning message), why do we need to have such complicated
preprocessor magic to guess at what the alignment is?  Would it be easier to
have GCC just define __GCC_MAX_ALIGNMENT__ or something similar for all
targets, and then use that in the test?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug testsuite/108150] gcc.dg/attr-aligned.c fails with incorrect max alignment
  2022-12-17  1:40 [Bug c/108150] New: gcc.dg/attr-aligned.c fails with incorrect max alignment nightstrike at gmail dot com
  2022-12-19  8:19 ` [Bug testsuite/108150] " nightstrike at gmail dot com
  2022-12-27 22:43 ` nightstrike at gmail dot com
@ 2023-01-08  1:33 ` 10walls at gmail dot com
  2023-01-28 16:32 ` cvs-commit at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: 10walls at gmail dot com @ 2023-01-08  1:33 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108150

--- Comment #3 from jon_y <10walls at gmail dot com> ---
Created attachment 54211
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54211&action=edit
Fix attempt 1

Makes errors emitted same as on Linux.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug testsuite/108150] gcc.dg/attr-aligned.c fails with incorrect max alignment
  2022-12-17  1:40 [Bug c/108150] New: gcc.dg/attr-aligned.c fails with incorrect max alignment nightstrike at gmail dot com
                   ` (2 preceding siblings ...)
  2023-01-08  1:33 ` 10walls at gmail dot com
@ 2023-01-28 16:32 ` cvs-commit at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-01-28 16:32 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108150

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jonathan Yong <jyong@gcc.gnu.org>:

https://gcc.gnu.org/g:ff3d99c5e72126cf8d4c7611a63a82dfc476cdbe

commit r13-5474-gff3d99c5e72126cf8d4c7611a63a82dfc476cdbe
Author: Jonathan Yong <10walls@gmail.com>
Date:   Sun Jan 8 01:28:34 2023 +0000

    PR c/108150 - Fix alignment test for Windows targets

    gcc/testsuite/ChangeLog:

            PR c/108150
            * gcc.dg/attr-aligned.c: Make errors emitted on Windows
            target same as on Linux.

    Signed-off-by: Jonathan Yong <10walls@gmail.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-01-28 16:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-17  1:40 [Bug c/108150] New: gcc.dg/attr-aligned.c fails with incorrect max alignment nightstrike at gmail dot com
2022-12-19  8:19 ` [Bug testsuite/108150] " nightstrike at gmail dot com
2022-12-27 22:43 ` nightstrike at gmail dot com
2023-01-08  1:33 ` 10walls at gmail dot com
2023-01-28 16:32 ` cvs-commit at gcc dot gnu.org

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).