Bug 116395 - -m32 forbids empty scalar initializer
Summary: -m32 forbids empty scalar initializer
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 11.4.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-08-16 19:34 UTC by Stas Sergeev
Modified: 2024-08-16 20:02 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
test case (37.09 KB, application/gzip)
2024-08-16 19:34 UTC, Stas Sergeev
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Stas Sergeev 2024-08-16 19:34:26 UTC
Created attachment 58941 [details]
test case

$ gunzip a.c.gz
$ gcc -c a.c
[ no output ]
$ gcc -m32 -c a.c
doprnt.c: In function ‘_doprnt’:
doprnt.c:144:27: error: empty scalar initializer
  144 |   va_list to_be_printed = {};        /* argument to be printed if numeric specifier are used */
      |                           ^
doprnt.c:144:27: note: (near initialization for ‘to_be_printed’)


I tried the trivial test-cases, but they pass.
But in this particular file any empty scalar initializers
are forbidden with -m32.
Comment 1 Andrew Pinski 2024-08-16 19:46:21 UTC
va_list can't be used that way.
in x86 (32bit) va_list is a pointer while in x86_64, it is an array.
Comment 2 Andrew Pinski 2024-08-16 19:48:02 UTC
va_list can only be assigned to via another va_list, initialized using va_start or va_copy.
Comment 3 Stas Sergeev 2024-08-16 19:49:51 UTC
(In reply to Andrew Pinski from comment #1)
> va_list can't be used that way.
> in x86 (32bit) va_list is a pointer while in x86_64, it is an array.

https://stackoverflow.com/questions/77647307/expression-int-a-why-a-is-null
So isn't the {} an universal initializer that can
be used on pointers too? The above article says it is...
Comment 4 Andrew Pinski 2024-08-16 19:53:04 UTC
(In reply to Stas Sergeev from comment #3)
> (In reply to Andrew Pinski from comment #1)
> > va_list can't be used that way.
> > in x86 (32bit) va_list is a pointer while in x86_64, it is an array.
> 
> https://stackoverflow.com/questions/77647307/expression-int-a-why-a-is-null
> So isn't the {} an universal initializer that can
> be used on pointers too? The above article says it is...

Yes it was not supported in GCC 11 as such as GCC 11 didn't have this support from C23, it was add in GCC 13.
Comment 5 Stas Sergeev 2024-08-16 19:57:36 UTC
Thank you.
Then its not INVALID, but rather is FIXED.
Comment 6 Andrew Pinski 2024-08-16 20:02:04 UTC
It is invalid since it is not being backported ...