public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug other/96287] New: Empty string argument to gcc should be ignored
@ 2020-07-22 15:07 andreas.urban at hotmail dot com
  2020-07-22 16:30 ` [Bug other/96287] " redi at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: andreas.urban at hotmail dot com @ 2020-07-22 15:07 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 96287
           Summary: Empty string argument to gcc should be ignored
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: other
          Assignee: unassigned at gcc dot gnu.org
          Reporter: andreas.urban at hotmail dot com
  Target Milestone: ---

Passing an empty string to GCC makes it look for a file named as such:

$ gcc --version
gcc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516
$ gcc
gcc: fatal error: no input files
compilation terminated.
$ gcc ""
gcc: error: : No such file or directory
gcc: fatal error: no input files
compilation terminated.

This is inconvenient for shells invoking other programs with a list of
arguments, such as Perl, Ruby, and Tcl, as you would have to remove the empty
strings from the argument list before executing command.

My suggestion is to have gcc ignore empty string arguments instead of treating
it as a filename. This will make integration with said languages and others
simpler at almost no cost.

Since empty string is not a supported filename for any mainstream filesystem,
and a terrible choice of name where supported, I see no apparent risk of
compatibility problems.

"Define errors out of existence" - John Ousterhout

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

* [Bug other/96287] Empty string argument to gcc should be ignored
  2020-07-22 15:07 [Bug other/96287] New: Empty string argument to gcc should be ignored andreas.urban at hotmail dot com
@ 2020-07-22 16:30 ` redi at gcc dot gnu.org
  2020-07-22 17:09 ` schwab@linux-m68k.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2020-07-22 16:30 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Ignoring it could lead to equally undesirable behaviour though.

for file in *.cc ; do gcc "$fil" ; done

Don't those languages support something like the Bourne shell's "$@" which does
the right thing?

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

* [Bug other/96287] Empty string argument to gcc should be ignored
  2020-07-22 15:07 [Bug other/96287] New: Empty string argument to gcc should be ignored andreas.urban at hotmail dot com
  2020-07-22 16:30 ` [Bug other/96287] " redi at gcc dot gnu.org
@ 2020-07-22 17:09 ` schwab@linux-m68k.org
  2020-07-22 17:17 ` andreas.urban at hotmail dot com
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: schwab@linux-m68k.org @ 2020-07-22 17:09 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Andreas Schwab <schwab@linux-m68k.org> ---
If you pass a non-file-name where a file name is expected you are doing
something wrong, and you need to fix *that*.  Hiding errors is doing a
disservice.

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

* [Bug other/96287] Empty string argument to gcc should be ignored
  2020-07-22 15:07 [Bug other/96287] New: Empty string argument to gcc should be ignored andreas.urban at hotmail dot com
  2020-07-22 16:30 ` [Bug other/96287] " redi at gcc dot gnu.org
  2020-07-22 17:09 ` schwab@linux-m68k.org
@ 2020-07-22 17:17 ` andreas.urban at hotmail dot com
  2020-07-22 18:01 ` andreas.urban at hotmail dot com
  2020-07-22 18:04 ` andreas.urban at hotmail dot com
  4 siblings, 0 replies; 6+ messages in thread
From: andreas.urban at hotmail dot com @ 2020-07-22 17:17 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Andreas Urban <andreas.urban at hotmail dot com> ---
(In reply to Jonathan Wakely from comment #1)
> Ignoring it could lead to equally undesirable behaviour though.
> 
> for file in *.cc ; do gcc "$fil" ; done
> 
> Don't those languages support something like the Bourne shell's "$@" which
> does the right thing?

Tcl has {*} expanding a list to be treated as arguments. Empty elements
disappear. Thinking about it some more, yes that behaves as intended and is
relatively easy to read and write:

exec gcc {*}$cppflags {*}$cflags -o $@ $<

So we can cross out Tcl from the list of languages that benefit from such
change.

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

* [Bug other/96287] Empty string argument to gcc should be ignored
  2020-07-22 15:07 [Bug other/96287] New: Empty string argument to gcc should be ignored andreas.urban at hotmail dot com
                   ` (2 preceding siblings ...)
  2020-07-22 17:17 ` andreas.urban at hotmail dot com
@ 2020-07-22 18:01 ` andreas.urban at hotmail dot com
  2020-07-22 18:04 ` andreas.urban at hotmail dot com
  4 siblings, 0 replies; 6+ messages in thread
From: andreas.urban at hotmail dot com @ 2020-07-22 18:01 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Andreas Urban <andreas.urban at hotmail dot com> ---
Looking closer at how Perl exec works, along with join on empty strings and
variable, there would seem to be no problem:

exec 'gcc', join(' ', @cppflags, @cflags, '-o', '$@', '$<')

There may be one or two things off in above line but from my experiments on
join and exec it behaves as one would want for empty arrays.

I'm now convinced this is not a big issue. Closing issue.

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

* [Bug other/96287] Empty string argument to gcc should be ignored
  2020-07-22 15:07 [Bug other/96287] New: Empty string argument to gcc should be ignored andreas.urban at hotmail dot com
                   ` (3 preceding siblings ...)
  2020-07-22 18:01 ` andreas.urban at hotmail dot com
@ 2020-07-22 18:04 ` andreas.urban at hotmail dot com
  4 siblings, 0 replies; 6+ messages in thread
From: andreas.urban at hotmail dot com @ 2020-07-22 18:04 UTC (permalink / raw)
  To: gcc-bugs

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

Andreas Urban <andreas.urban at hotmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #5 from Andreas Urban <andreas.urban at hotmail dot com> ---
Withdrawing proposal. Alternative solutions found satisfactory.

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

end of thread, other threads:[~2020-07-22 18:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-22 15:07 [Bug other/96287] New: Empty string argument to gcc should be ignored andreas.urban at hotmail dot com
2020-07-22 16:30 ` [Bug other/96287] " redi at gcc dot gnu.org
2020-07-22 17:09 ` schwab@linux-m68k.org
2020-07-22 17:17 ` andreas.urban at hotmail dot com
2020-07-22 18:01 ` andreas.urban at hotmail dot com
2020-07-22 18:04 ` andreas.urban at hotmail dot com

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