Bug 70649 - [6 Regression] Incorrect C++ warning on zero-sized array passing
Summary: [6 Regression] Incorrect C++ warning on zero-sized array passing
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 6.0
: P3 normal
Target Milestone: 6.0
Assignee: Jason Merrill
URL:
Keywords: ABI, diagnostic
Depends on:
Blocks:
 
Reported: 2016-04-14 00:34 UTC by H.J. Lu
Modified: 2016-04-14 16:24 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2016-04-14 00:00:00


Attachments
fix (1.02 KB, patch)
2016-04-14 16:11 UTC, Jason Merrill
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2016-04-14 00:34:27 UTC
[hjl@gnu-6 pr60336d]$ cat x.i
struct dummy0 { int i; };
struct dummy { struct dummy0 d[0]; };
extern void fun(struct dummy, int);
void
foo (void)
{
  struct dummy d;
  fun(d, 1);
}
[hjl@gnu-6 pr60336d]$ g++ -S -Wabi=9 x.i 
[hjl@gnu-6 pr60336d]$ cat x.s
	.file	"x.i"
	.text
	.globl	_Z3foov
	.type	_Z3foov, @function
_Z3foov:
.LFB0:
	.cfi_startproc
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	$1, %edi
	call	_Z3fun5dummyi
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	_Z3foov, .-_Z3foov
	.ident	"GCC: (GNU) 5.3.1 20160406 (Red Hat 5.3.1-6)"
	.section	.note.GNU-stack,"",@progbits
[hjl@gnu-6 pr60336d]$ /export/build/gnu/gcc-x32/build-x86_64-linux/gcc/xg++ -B/export/build/gnu/gcc-x32/build-x86_64-linux/gcc/ -S -Wabi=9 x.i 
x.i: In function ‘void foo()’:
x.i:8:12: warning: call to ‘fun’: empty class ‘dummy’ parameter passing ABI changes in -fabi-version=10 (GCC 6) [-Wabi]
   fun(d, 1);
            ^
[hjl@gnu-6 pr60336d]$ cat x.s
	.file	"x.i"
	.text
	.globl	_Z3foov
	.type	_Z3foov, @function
_Z3foov:
.LFB0:
	.cfi_startproc
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	$1, %edi
	call	_Z3fun5dummyi
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	_Z3foov, .-_Z3foov
	.ident	"GCC: (GNU) 6.0.0 20160413 (experimental)"
	.section	.note.GNU-stack,"",@progbits
[hjl@gnu-6 pr60336d]$ 

The warning is incorrect since there is no change in zero-sized array passing.
Comment 1 Jason Merrill 2016-04-14 16:11:17 UTC
Created attachment 38272 [details]
fix
Comment 2 Jason Merrill 2016-04-14 16:24:52 UTC
Fixed by reverting the ABI change.